summaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-08 16:17:12 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-10 14:51:33 +0100
commit8b2dec6ab771c74815ae6d3358c8e58cf7815f23 (patch)
tree9146fb742b1fd4dd1b6c6e599fe230b0c83a3441 /lib/http.c
parent83f1ca69290f9d6198fe4013488408f94736c5dc (diff)
downloadcurl-8b2dec6ab771c74815ae6d3358c8e58cf7815f23.tar.gz
http: make 'authneg' also work for Hyper
When doing a request with a request body expecting a 401/407 back, that initial request is sent with a zero content-length. Test 177 and more. Closes #6424
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/http.c b/lib/http.c
index 42aa84ec0..8bee326f4 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -784,6 +784,7 @@ output_auth_headers(struct connectdata *conn,
CURLcode
Curl_http_output_auth(struct connectdata *conn,
const char *request,
+ Curl_HttpReq httpreq,
const char *path,
bool proxytunnel) /* TRUE if this is the request setting
up the proxy tunnel */
@@ -850,6 +851,17 @@ Curl_http_output_auth(struct connectdata *conn,
else
authhost->done = TRUE;
+ if(((authhost->multipass && !authhost->done) ||
+ (authproxy->multipass && !authproxy->done)) &&
+ (httpreq != HTTPREQ_GET) &&
+ (httpreq != HTTPREQ_HEAD)) {
+ /* Auth is required and we are not authenticated yet. Make a PUT or POST
+ with content-length zero as a "probe". */
+ conn->bits.authneg = TRUE;
+ }
+ else
+ conn->bits.authneg = FALSE;
+
return result;
}
@@ -1962,7 +1974,7 @@ void Curl_http_method(struct Curl_easy *data, struct connectdata *conn,
if(data->set.opt_no_body)
request = "HEAD";
else {
- DEBUGASSERT((httpreq > HTTPREQ_NONE) && (httpreq < HTTPREQ_LAST));
+ DEBUGASSERT((httpreq >= HTTPREQ_GET) && (httpreq <= HTTPREQ_HEAD));
switch(httpreq) {
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
@@ -2972,24 +2984,13 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(!pq)
return CURLE_OUT_OF_MEMORY;
}
- result = Curl_http_output_auth(conn, request,
+ result = Curl_http_output_auth(conn, request, httpreq,
(pq ? pq : data->state.up.path), FALSE);
free(pq);
if(result)
return result;
}
- if(((data->state.authhost.multipass && !data->state.authhost.done)
- || (data->state.authproxy.multipass && !data->state.authproxy.done)) &&
- (httpreq != HTTPREQ_GET) &&
- (httpreq != HTTPREQ_HEAD)) {
- /* Auth is required and we are not authenticated yet. Make a PUT or POST
- with content-length zero as a "probe". */
- conn->bits.authneg = TRUE;
- }
- else
- conn->bits.authneg = FALSE;
-
Curl_safefree(data->state.aptr.ref);
if(data->change.referer && !Curl_checkheaders(conn, "Referer")) {
data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer);