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