mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 05:27:38 +03:00
2007-03-19 Tatsuhiro Tsujikawa <tujikawa at valkyrie dot rednoah com>
To integrate Netrc into exsiting classes: * src/Request.h (_userDefinedAuthConfig): New variable. (findNetrcAuthenticator): New function. (segment): Removed. (setUserDefinedAuthConfig): New function. (resolveHttpAuthConfigItem): New function. (resolveFtpAuthConfigItem): New function. (resolveHttpProxyAuthConfigItem): New function. * src/HttpRequest.h (authConfig): Removed. (proxyAuthConfig): Removed. (setAuthConfig): Removed. (setProxyAuthConfig): Removed. * src/UrlRequest.h (getHeadResult): Added a parameter: authConfigHandle * src/common.h (SingletonHolder.h): New include. * src/main.cc (Netrc.h): New include. (main): Removed initial values of PREF_FTP_USER, PREF_FTP_PASSWD. Added initial value of PREF_NETRC_PATH. Added the initialization of netrc. * src/AuthConfig.h: New class. * src/prefs.h (PREF_NETRC_PATH): New definition. * src/HttpAuthConfig.h: Removed. * src/Netrc.cc (getRequiredNextToken): New function. (skipMacdef): New function. (parse): Rewritten. * src/Netrc.h (getRequiredNextToken): New function. (skipMacdef): New function. * src/Util.h, src/Util.cc (getHomeDir): New function. * src/TrackerWatcherComand.cc (createRequestCommand): Use AuthConfig. * src/FtpConnection.cc (sendUser): Use Request::resolveFtpAuthConfigItem(). (sendPass): Use Request::resolveFtpAuthConfigItem(). * src/Request.cc (findNetrcAuthenticator): New function. (resolveHttpAuthConfigItem): New function. (resolveFtpAuthConfigItem): New function. (resolveHttpProxyAuthConfigItem): New function. * src/UrlRequestInfo.cc: Use AuthConfig. * src/HttpRequest.cc (createRequest): Use authConfig. (getProxyAuthString): Use authConfig. (configure): Removed PREF_HTTP_USER, PREF_HTTP_PASSWD, PREF_HTTP_PROXY_USER, PREF_HTTP_PROXY_PASSWD.
This commit is contained in:
parent
58d4dde223
commit
7ff627079f
29 changed files with 685 additions and 100 deletions
|
@ -81,6 +81,9 @@ void HttpRequestTest::testCreateRequest()
|
|||
{
|
||||
RequestHandle request = new Request();
|
||||
request->setUrl("http://localhost:8080/archives/aria2-1.0.0.tar.bz2");
|
||||
AuthConfigHandle authConfig = new AuthConfig();
|
||||
request->setUserDefinedAuthConfig(authConfig);
|
||||
|
||||
SegmentHandle segment = new Segment();
|
||||
|
||||
HttpRequest httpRequest;
|
||||
|
@ -168,6 +171,7 @@ void HttpRequestTest::testCreateRequest()
|
|||
option->put(PREF_HTTP_PROXY_USER, "aria2proxyuser");
|
||||
option->put(PREF_HTTP_PROXY_PASSWD, "aria2proxypasswd");
|
||||
|
||||
authConfig->configure(option.get());
|
||||
httpRequest.configure(option.get());
|
||||
|
||||
expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
|
@ -278,6 +282,8 @@ void HttpRequestTest::testCreateRequest_ftp()
|
|||
{
|
||||
RequestHandle request = new Request();
|
||||
request->setUrl("ftp://localhost:8080/archives/aria2-1.0.0.tar.bz2");
|
||||
AuthConfigHandle authConfig = new AuthConfig();
|
||||
request->setUserDefinedAuthConfig(authConfig);
|
||||
SegmentHandle segment = new Segment();
|
||||
|
||||
HttpRequest httpRequest;
|
||||
|
@ -296,6 +302,7 @@ void HttpRequestTest::testCreateRequest_ftp()
|
|||
option->put(PREF_HTTP_PROXY_PASSWD, "aria2proxypasswd");
|
||||
|
||||
httpRequest.configure(option.get());
|
||||
authConfig->configure(option.get());
|
||||
|
||||
string expectedText = "GET ftp://localhost:8080/archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
|
||||
"User-Agent: aria2\r\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue