Explorar o código

add no-want-digest-header option

carsonzhu %!s(int64=3) %!d(string=hai) anos
pai
achega
839dd2caf7
Modificáronse 6 ficheiros con 23 adicións e 0 borrados
  1. 4 0
      doc/manual-src/en/aria2c.rst
  2. 2 0
      src/HttpRequestCommand.cc
  3. 10 0
      src/OptionHandlerFactory.cc
  4. 2 0
      src/prefs.cc
  5. 2 0
      src/prefs.h
  6. 3 0
      src/usage_text.h

+ 4 - 0
doc/manual-src/en/aria2c.rst

@@ -557,6 +557,10 @@ HTTP Specific Options
   Use HEAD method for the first request to the HTTP server.
   Default: ``false``
 
+.. option:: --no-want-digest-header [true|false]
+
+  Whether to disable Want-Digest header when doing requests.
+  Default: ``false``
 
 .. option:: -U, --user-agent=<USER_AGENT>
 

+ 2 - 0
src/HttpRequestCommand.cc

@@ -99,6 +99,8 @@ createHttpRequest(const std::shared_ptr<Request>& req,
   httpRequest->setOption(option.get());
   httpRequest->setProxyRequest(proxyRequest);
   httpRequest->setAcceptMetalink(rg->getDownloadContext()->getAcceptMetalink());
+  httpRequest->setNoWantDigest(option->getAsBool(PREF_NO_WANT_DIGEST_HEADER));
+
   if (option->getAsBool(PREF_HTTP_ACCEPT_GZIP)) {
     httpRequest->enableAcceptGZip();
   }

+ 10 - 0
src/OptionHandlerFactory.cc

@@ -1205,6 +1205,16 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
     op->setChangeOptionForReserved(true);
     handlers.push_back(op);
   }
+  {
+    OptionHandler* op(new BooleanOptionHandler(
+        PREF_NO_WANT_DIGEST_HEADER, TEXT_NO_WANT_DIGEST_HEADER, A2_V_FALSE,
+        OptionHandler::OPT_ARG));
+    op->addTag(TAG_HTTP);
+    op->setInitialOption(true);
+    op->setChangeGlobalOption(true);
+    op->setChangeOptionForReserved(true);
+    handlers.push_back(op);
+  }
   {
     OptionHandler* op(new DefaultOptionHandler(
         PREF_USER_AGENT, TEXT_USER_AGENT, "aria2/" PACKAGE_VERSION, A2STR::NIL,

+ 2 - 0
src/prefs.cc

@@ -429,6 +429,8 @@ PrefPtr PREF_HTTP_ACCEPT_GZIP = makePref("http-accept-gzip");
 // value: true | false
 PrefPtr PREF_CONTENT_DISPOSITION_DEFAULT_UTF8 =
     makePref("content-disposition-default-utf8");
+// value: true | false
+PrefPtr PREF_NO_WANT_DIGEST_HEADER = makePref("no-want-digest-header");
 
 /**
  * Proxy related preferences

+ 2 - 0
src/prefs.h

@@ -381,6 +381,8 @@ extern PrefPtr PREF_HTTP_NO_CACHE;
 extern PrefPtr PREF_HTTP_ACCEPT_GZIP;
 // value: true | false
 extern PrefPtr PREF_CONTENT_DISPOSITION_DEFAULT_UTF8;
+// value: true | false
+extern PrefPtr PREF_NO_WANT_DIGEST_HEADER;
 
 /**;
  * Proxy related preferences

+ 3 - 0
src/usage_text.h

@@ -539,6 +539,9 @@
 #define TEXT_USE_HEAD                                                   \
   _(" --use-head[=true|false]      Use HEAD method for the first request to the HTTP\n" \
     "                              server.")
+#define TEXT_NO_WANT_DIGEST_HEADER                                      \
+  _(" --no-want-digest-header[=true|false] Whether to disable Want-Digest header \n" \
+    "                              when doing requests.")
 #define TEXT_CONTENT_DISPOSITION_DEFAULT_UTF8                          \
   _(" --content-disposition-default-utf8[=true|false] Handle quoted string in\n" \
     "                              Content-Disposition header as UTF-8 instead of\n" \