Explorar o código

2010-01-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Now --all-proxy, --http-proxy, --https-proxy and --ftp-proxy
	option accepts empty string "".  When "" is given, it erases
	previously defined proxy.
	* doc/aria2c.1.txt
	* src/OptionHandlerImpl.h
	* src/usage_text.h
	* test/OptionHandlerTest.cc
Tatsuhiro Tsujikawa %!s(int64=15) %!d(string=hai) anos
pai
achega
c022939c8f
Modificáronse 7 ficheiros con 73 adicións e 47 borrados
  1. 10 0
      ChangeLog
  2. 6 6
      doc/aria2c.1
  3. 14 14
      doc/aria2c.1.html
  4. 17 13
      doc/aria2c.1.txt
  5. 14 10
      src/OptionHandlerImpl.h
  6. 8 4
      src/usage_text.h
  7. 4 0
      test/OptionHandlerTest.cc

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+2010-01-15  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Now --all-proxy, --http-proxy, --https-proxy and --ftp-proxy
+	option accepts empty string "".  When "" is given, it erases
+	previously defined proxy.
+	* doc/aria2c.1.txt
+	* src/OptionHandlerImpl.h
+	* src/usage_text.h
+	* test/OptionHandlerTest.cc
+
 2010-01-15  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Code cleanup for proxy URI handling.

+ 6 - 6
doc/aria2c.1

@@ -2,12 +2,12 @@
 .\"     Title: aria2c
 .\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
-.\"      Date: 01/12/2010
+.\"      Date: 01/15/2010
 .\"    Manual: Aria2 Manual
 .\"    Source: Aria2
 .\"  Language: English
 .\"
-.TH "ARIA2C" "1" "01/12/2010" "Aria2" "Aria2 Manual"
+.TH "ARIA2C" "1" "01/15/2010" "Aria2" "Aria2 Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -107,7 +107,7 @@ Default:
 .PP
 \fB\-\-all\-proxy\fR=PROXY
 .RS 4
-Use this proxy server for all protocols\&. You can override this setting and specify a proxy server for a particular protocol using
+Use this proxy server for all protocols\&. To erase previously defined proxy, use ""\&. You can override this setting and specify a proxy server for a particular protocol using
 \fB\-\-http\-proxy\fR,
 \fB\-\-https\-proxy\fR
 and
@@ -328,14 +328,14 @@ Set HTTP password\&. This affects all URLs\&.
 .PP
 \fB\-\-http\-proxy\fR=PROXY
 .RS 4
-Use this proxy server for HTTP\&. See also
+Use this proxy server for HTTP\&. To erase previously defined proxy, use ""\&. See also
 \fB\-\-all\-proxy\fR
 option\&. This affects all URLs\&. The format of PROXY is [http://][USER:PASSWORD@]HOST[:PORT]
 .RE
 .PP
 \fB\-\-https\-proxy\fR=PROXY
 .RS 4
-Use this proxy server for HTTPS\&. See also
+Use this proxy server for HTTPS\&. To erase previously defined proxy, use ""\&. See also
 \fB\-\-all\-proxy\fR
 option\&. This affects all URLs\&. The format of PROXY is [http://][USER:PASSWORD@]HOST[:PORT]
 .RE
@@ -433,7 +433,7 @@ is given, the active mode will be used\&. Default:
 .PP
 \fB\-\-ftp\-proxy\fR=PROXY
 .RS 4
-Use this proxy server for FTP\&. See also
+Use this proxy server for FTP\&. To erase previously defined proxy, use ""\&. See also
 \fB\-\-all\-proxy\fR
 option\&. This affects all URLs\&. The format of PROXY is [http://][USER:PASSWORD@]HOST[:PORT]
 .RE

+ 14 - 14
doc/aria2c.1.html

@@ -678,10 +678,10 @@ downloading a file like BitTorrent.</p></div>
 </dt>
 <dd>
 <p>
-  Use this proxy server for all protocols.
-  You can override this setting and specify a proxy server for a particular
-  protocol using <strong>--http-proxy</strong>, <strong>--https-proxy</strong> and <strong>--ftp-proxy</strong> options.
-  This affects all URLs.
+  Use this proxy server for all protocols.  To erase previously
+  defined proxy, use "".  You can override this setting and specify a
+  proxy server for a particular protocol using <strong>--http-proxy</strong>,
+  <strong>--https-proxy</strong> and <strong>--ftp-proxy</strong> options.  This affects all URLs.
   The format of PROXY is [<a href="http://][USER:PASSWORD@]HOST[:PORT">http://][USER:PASSWORD@]HOST[:PORT</a>]
 </p>
 </dd>
@@ -955,9 +955,9 @@ aria2c -o myfile.zip "http://mirror1/file.zip" "http://mirror2/file.zip"</td>
 </dt>
 <dd>
 <p>
-  Use this proxy server for HTTP. See also <strong>--all-proxy</strong> option.
-  This affects all URLs.
-  The format of PROXY is [<a href="http://][USER:PASSWORD@]HOST[:PORT">http://][USER:PASSWORD@]HOST[:PORT</a>]
+  Use this proxy server for HTTP.  To erase previously defined proxy,
+  use "".  See also <strong>--all-proxy</strong> option.  This affects all URLs.  The
+  format of PROXY is [<a href="http://][USER:PASSWORD@]HOST[:PORT">http://][USER:PASSWORD@]HOST[:PORT</a>]
 </p>
 </dd>
 <dt class="hdlist1">
@@ -965,9 +965,9 @@ aria2c -o myfile.zip "http://mirror1/file.zip" "http://mirror2/file.zip"</td>
 </dt>
 <dd>
 <p>
-  Use this proxy server for HTTPS. See also <strong>--all-proxy</strong> option.
-  This affects all URLs.
-  The format of PROXY is [<a href="http://][USER:PASSWORD@]HOST[:PORT">http://][USER:PASSWORD@]HOST[:PORT</a>]
+  Use this proxy server for HTTPS. To erase previously defined proxy,
+  use "". See also <strong>--all-proxy</strong> option.  This affects all URLs.  The
+  format of PROXY is [<a href="http://][USER:PASSWORD@]HOST[:PORT">http://][USER:PASSWORD@]HOST[:PORT</a>]
 </p>
 </dd>
 <dt class="hdlist1">
@@ -1105,9 +1105,9 @@ aria2c -o myfile.zip "http://mirror1/file.zip" "http://mirror2/file.zip"</td>
 </dt>
 <dd>
 <p>
-  Use this proxy server for FTP. See also <strong>--all-proxy</strong> option.
-  This affects all URLs.
-  The format of PROXY is [<a href="http://][USER:PASSWORD@]HOST[:PORT">http://][USER:PASSWORD@]HOST[:PORT</a>]
+  Use this proxy server for FTP.  To erase previously defined proxy,
+  use "".  See also <strong>--all-proxy</strong> option.  This affects all URLs.  The
+  format of PROXY is [<a href="http://][USER:PASSWORD@]HOST[:PORT">http://][USER:PASSWORD@]HOST[:PORT</a>]
 </p>
 </dd>
 <dt class="hdlist1">
@@ -3578,7 +3578,7 @@ files in the program, then also delete it here.</p></div>
 <div id="footnotes"><hr /></div>
 <div id="footer">
 <div id="footer-text">
-Last updated 2010-01-12 23:26:20 JST
+Last updated 2010-01-15 17:58:00 JST
 </div>
 </div>
 </body>

+ 17 - 13
doc/aria2c.1.txt

@@ -76,10 +76,11 @@ Basic Options
 HTTP/FTP Options
 ~~~~~~~~~~~~~~~~
 *--all-proxy*=PROXY::
-  Use this proxy server for all protocols.
-  You can override this setting and specify a proxy server for a particular
-  protocol using *--http-proxy*, *--https-proxy* and *--ftp-proxy* options.
-  This affects all URLs.
+
+  Use this proxy server for all protocols.  To erase previously
+  defined proxy, use "".  You can override this setting and specify a
+  proxy server for a particular protocol using *--http-proxy*,
+  *--https-proxy* and *--ftp-proxy* options.  This affects all URLs.
   The format of PROXY is [\http://][USER:PASSWORD@]HOST[:PORT]
 
 *--connect-timeout*=SEC::
@@ -227,14 +228,16 @@ HTTP Specific Options
   Set HTTP password. This affects all URLs.
 
 *--http-proxy*=PROXY::
-  Use this proxy server for HTTP. See also *--all-proxy* option.
-  This affects all URLs.
-  The format of PROXY is [\http://][USER:PASSWORD@]HOST[:PORT]
+
+  Use this proxy server for HTTP.  To erase previously defined proxy,
+  use "".  See also *--all-proxy* option.  This affects all URLs.  The
+  format of PROXY is [\http://][USER:PASSWORD@]HOST[:PORT]
 
 *--https-proxy*=PROXY::
-  Use this proxy server for HTTPS. See also *--all-proxy* option.
-  This affects all URLs.
-  The format of PROXY is [\http://][USER:PASSWORD@]HOST[:PORT]
+
+  Use this proxy server for HTTPS. To erase previously defined proxy,
+  use "". See also *--all-proxy* option.  This affects all URLs.  The
+  format of PROXY is [\http://][USER:PASSWORD@]HOST[:PORT]
 
 *--private-key*=FILE::
   Use the private key in FILE.
@@ -301,9 +304,10 @@ FTP Specific Options
   Default: 'true'
 
 *--ftp-proxy*=PROXY::
-  Use this proxy server for FTP. See also *--all-proxy* option.
-  This affects all URLs.
-  The format of PROXY is [\http://][USER:PASSWORD@]HOST[:PORT]
+
+  Use this proxy server for FTP.  To erase previously defined proxy,
+  use "".  See also *--all-proxy* option.  This affects all URLs.  The
+  format of PROXY is [\http://][USER:PASSWORD@]HOST[:PORT]
 
 *--ftp-type*=TYPE::
   Set FTP transfer type. TYPE is either 'binary' or 'ascii'.

+ 14 - 10
src/OptionHandlerImpl.h

@@ -556,17 +556,21 @@ public:
 
   virtual void parseArg(Option& option, const std::string& optarg)
   {
-    Request req;
-    std::string url;
-    if(util::startsWith(optarg, "http://")) {
-      url = optarg;
-    } else {
-      url = "http://"+optarg;
-    }
-    if(req.setUrl(url)) {
-      option.put(_optName, url);
+    if(optarg.empty()) {
+      option.put(_optName, optarg);
     } else {
-      throw DL_ABORT_EX(_("unrecognized proxy format"));
+      Request req;
+      std::string url;
+      if(util::startsWith(optarg, "http://")) {
+        url = optarg;
+      } else {
+        url = "http://"+optarg;
+      }
+      if(req.setUrl(url)) {
+        option.put(_optName, url);
+      } else {
+        throw DL_ABORT_EX(_("unrecognized proxy format"));
+      }
     }
   }
 

+ 8 - 4
src/usage_text.h

@@ -63,19 +63,23 @@
 #define TEXT_MAX_TRIES                                                  \
   _(" -m, --max-tries=N            Set number of tries. 0 means unlimited.")
 #define TEXT_HTTP_PROXY                                                 \
-  _(" --http-proxy=PROXY           Use this proxy server for HTTP.\n"   \
+  _(" --http-proxy=PROXY           Use this proxy server for HTTP. To erase\n"\
+    "                              previously defined proxy, use \"\".\n"   \
     "                              See also  --all-proxy option.\n"     \
     "                              This affects all URLs.")
 #define TEXT_HTTPS_PROXY                                                \
-  _(" --https-proxy=PROXY          Use this proxy server for HTTPS.\n"  \
+  _(" --https-proxy=PROXY          Use this proxy server for HTTPS. To erase\n"  \
+    "                              previously defined proxy, use \"\".\n" \
     "                              See also  --all-proxy option.\n"     \
     "                              This affects all URLs.")
 #define TEXT_FTP_PROXY                                                  \
-  _(" --ftp-proxy=PROXY            Use this proxy server for FTP.\n"    \
+  _(" --ftp-proxy=PROXY            Use this proxy server for FTP. To erase previously\n"    \
+    "                              defined proxy, use \"\".\n" \
     "                              See also  --all-proxy option.\n"     \
     "                              This affects all URLs.")
 #define TEXT_ALL_PROXY                                                  \
-  _(" --all-proxy=PROXY            Use this proxy server for all protocols.\n" \
+  _(" --all-proxy=PROXY            Use this proxy server for all protocols. To erase\n" \
+    "                              previously defined proxy, use \"\".\n" \
     "                              You can override this setting and specify a\n" \
     "                              proxy server for a particular protocol using\n" \
     "                              --http-proxy, --https-proxy and --ftp-proxy\n" \

+ 4 - 0
test/OptionHandlerTest.cc

@@ -313,6 +313,10 @@ void OptionHandlerTest::testHttpProxyOptionHandler()
   CPPUNIT_ASSERT_EQUAL(std::string("http://proxy:8080"),
                        option.get(PREF_HTTP_PROXY));
 
+  handler.parse(option, "");
+  CPPUNIT_ASSERT(option.defined(PREF_HTTP_PROXY));
+  CPPUNIT_ASSERT(option.blank(PREF_HTTP_PROXY));
+
   try {
     handler.parse(option, "http://bar:65536");
     CPPUNIT_FAIL("exception must be thrown.");