|
| 1 | +From b938aa51e50852d1b185db3188357073ad374416 Mon Sep 17 00:00:00 2001 |
| 2 | +From: myfreeer < [email protected]> |
| 3 | +Date: Sun, 13 Dec 2020 15:40:56 +0800 |
| 4 | +Subject: [PATCH] option: add option to disable Want-Digest header |
| 5 | + |
| 6 | +Sending this HTTP header should be optional. |
| 7 | +Should close https://github.com/myfreeer/aria2-build-msys2/issues/10 |
| 8 | + |
| 9 | + --http-want-digest[=true|false] Send Want-Digest HTTP requser header |
| 10 | + with only limited hash algorithms: |
| 11 | + SHA-512, SHA-256, and SHA-1. |
| 12 | + The Want-Digest HTTP header is primarily used |
| 13 | + in a HTTP request, to ask the responder to |
| 14 | + provide a digest of the requested resource |
| 15 | + using the Digest response header |
| 16 | + |
| 17 | + Possible Values: true, false |
| 18 | + Default: true |
| 19 | + Tags: #advanced, #http |
| 20 | +--- |
| 21 | + src/AbstractProxyRequestCommand.cc | 1 + |
| 22 | + src/HttpRequestCommand.cc | 1 + |
| 23 | + src/OptionHandlerFactory.cc | 12 ++++++++++++ |
| 24 | + src/prefs.cc | 2 ++ |
| 25 | + src/prefs.h | 2 ++ |
| 26 | + src/usage_text.h | 8 ++++++++ |
| 27 | + 6 files changed, 26 insertions(+) |
| 28 | + |
| 29 | +diff --git a/src/AbstractProxyRequestCommand.cc b/src/AbstractProxyRequestCommand.cc |
| 30 | +index bd2bcb3..1feed07 100644 |
| 31 | +--- a/src/AbstractProxyRequestCommand.cc |
| 32 | ++++ b/src/AbstractProxyRequestCommand.cc |
| 33 | +@@ -72,6 +72,7 @@ bool AbstractProxyRequestCommand::executeInternal() |
| 34 | + if (httpConnection_->sendBufferIsEmpty()) { |
| 35 | + auto httpRequest = make_unique<HttpRequest>(); |
| 36 | + httpRequest->setUserAgent(getOption()->get(PREF_USER_AGENT)); |
| 37 | ++ httpRequest->setNoWantDigest(!getOption()->getAsBool(PREF_HTTP_WANT_DIGEST)); |
| 38 | + httpRequest->setRequest(getRequest()); |
| 39 | + httpRequest->setProxyRequest(proxyRequest_); |
| 40 | + |
| 41 | +diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc |
| 42 | +index a2b8e7e..8c50153 100644 |
| 43 | +--- a/src/HttpRequestCommand.cc |
| 44 | ++++ b/src/HttpRequestCommand.cc |
| 45 | +@@ -90,6 +90,7 @@ createHttpRequest(const std::shared_ptr<Request>& req, |
| 46 | + { |
| 47 | + auto httpRequest = make_unique<HttpRequest>(); |
| 48 | + httpRequest->setUserAgent(option->get(PREF_USER_AGENT)); |
| 49 | ++ httpRequest->setNoWantDigest(!option->getAsBool(PREF_HTTP_WANT_DIGEST)); |
| 50 | + httpRequest->setRequest(req); |
| 51 | + httpRequest->setFileEntry(fileEntry); |
| 52 | + httpRequest->setSegment(segment); |
| 53 | +diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc |
| 54 | +index a058eb9..9ff615a 100644 |
| 55 | +--- a/src/OptionHandlerFactory.cc |
| 56 | ++++ b/src/OptionHandlerFactory.cc |
| 57 | +@@ -1106,6 +1106,18 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers() |
| 58 | + op->setChangeOptionForReserved(true); |
| 59 | + handlers.push_back(op); |
| 60 | + } |
| 61 | ++ { |
| 62 | ++ OptionHandler* op( |
| 63 | ++ new BooleanOptionHandler(PREF_HTTP_WANT_DIGEST, |
| 64 | ++ TEXT_HTTP_WANT_DIGEST, |
| 65 | ++ A2_V_TRUE, OptionHandler::OPT_ARG)); |
| 66 | ++ op->addTag(TAG_ADVANCED); |
| 67 | ++ op->addTag(TAG_HTTP); |
| 68 | ++ op->setInitialOption(true); |
| 69 | ++ op->setChangeGlobalOption(true); |
| 70 | ++ op->setChangeOptionForReserved(true); |
| 71 | ++ handlers.push_back(op); |
| 72 | ++ } |
| 73 | + { |
| 74 | + OptionHandler* op(new BooleanOptionHandler( |
| 75 | + PREF_ENABLE_HTTP_KEEP_ALIVE, TEXT_ENABLE_HTTP_KEEP_ALIVE, A2_V_TRUE, |
| 76 | +diff --git a/src/prefs.cc b/src/prefs.cc |
| 77 | +index 9793706..bdb33e2 100644 |
| 78 | +--- a/src/prefs.cc |
| 79 | ++++ b/src/prefs.cc |
| 80 | +@@ -437,6 +437,8 @@ PrefPtr PREF_HTTP_ACCEPT_GZIP = makePref("http-accept-gzip"); |
| 81 | + // value: true | false |
| 82 | + PrefPtr PREF_CONTENT_DISPOSITION_DEFAULT_UTF8 = |
| 83 | + makePref("content-disposition-default-utf8"); |
| 84 | ++// values: true | false |
| 85 | ++PrefPtr PREF_HTTP_WANT_DIGEST = makePref("http-want-digest"); |
| 86 | + |
| 87 | + /** |
| 88 | + * Proxy related preferences |
| 89 | +diff --git a/src/prefs.h b/src/prefs.h |
| 90 | +index f014d9c..c88f2d0 100644 |
| 91 | +--- a/src/prefs.h |
| 92 | ++++ b/src/prefs.h |
| 93 | +@@ -389,6 +389,8 @@ extern PrefPtr PREF_HTTP_NO_CACHE; |
| 94 | + extern PrefPtr PREF_HTTP_ACCEPT_GZIP; |
| 95 | + // value: true | false |
| 96 | + extern PrefPtr PREF_CONTENT_DISPOSITION_DEFAULT_UTF8; |
| 97 | ++// value: true | false |
| 98 | ++extern PrefPtr PREF_HTTP_WANT_DIGEST; |
| 99 | + |
| 100 | + /**; |
| 101 | + * Proxy related preferences |
| 102 | +diff --git a/src/usage_text.h b/src/usage_text.h |
| 103 | +index 7a0a981..aee3ac0 100644 |
| 104 | +--- a/src/usage_text.h |
| 105 | ++++ b/src/usage_text.h |
| 106 | +@@ -560,6 +560,14 @@ |
| 107 | + " Content-Disposition header as UTF-8 instead of\n" \ |
| 108 | + " ISO-8859-1, for example, the filename parameter,\n" \ |
| 109 | + " but not the extended version filename*.") |
| 110 | ++#define TEXT_HTTP_WANT_DIGEST \ |
| 111 | ++ _(" --http-want-digest[=true|false] Send Want-Digest HTTP requser header\n" \ |
| 112 | ++ " with only limited hash algorithms:\n" \ |
| 113 | ++ " SHA-512, SHA-256, and SHA-1.\n" \ |
| 114 | ++ " The Want-Digest HTTP header is primarily used\n" \ |
| 115 | ++ " in a HTTP request, to ask the responder to\n" \ |
| 116 | ++ " provide a digest of the requested resource\n" \ |
| 117 | ++ " using the Digest response header") |
| 118 | + #define TEXT_EVENT_POLL \ |
| 119 | + _(" --event-poll=POLL Specify the method for polling events.") |
| 120 | + #define TEXT_BT_EXTERNAL_IP \ |
| 121 | +-- |
| 122 | +2.29.2 |
| 123 | + |
0 commit comments