urldata: move authneg bit from conn to Curl_easy

- from `conn->bits.authneg` to `data->req.authneg`
- this is a property of the request about to be made
  and not a property of the connection
- in multiuse connections, transfer could step on each others
  toes here potentially.

Closes #12949
This commit is contained in:
Stefan Eissing 2024-02-16 12:15:10 +01:00 committed by Daniel Stenberg
parent e925d0d1ff
commit 2254551403
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 25 additions and 26 deletions

View File

@ -696,7 +696,6 @@ static int uploadstreamed(void *userdata, hyper_context *ctx,
{
size_t fillcount;
struct Curl_easy *data = (struct Curl_easy *)userdata;
struct connectdata *conn = (struct connectdata *)data->conn;
CURLcode result;
(void)ctx;
@ -711,7 +710,7 @@ static int uploadstreamed(void *userdata, hyper_context *ctx,
return HYPER_POLL_PENDING;
}
if(data->req.upload_chunky && conn->bits.authneg) {
if(data->req.upload_chunky && data->req.authneg) {
fillcount = 0;
data->req.upload_chunky = FALSE;
result = CURLE_OK;
@ -1174,7 +1173,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"\r\n", 2);
if(data->req.upload_chunky && conn->bits.authneg) {
if(data->req.upload_chunky && data->req.authneg) {
data->req.upload_chunky = TRUE;
}
else {

View File

@ -447,7 +447,7 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
bytessent = data->req.writebytecount;
if(conn->bits.authneg) {
if(data->req.authneg) {
/* This is a state where we are known to be negotiating and we don't send
any data then. */
expectsend = 0;
@ -489,7 +489,7 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
data left to send, keep on sending. */
/* rewind data when completely done sending! */
if(!conn->bits.authneg && (conn->writesockfd != CURL_SOCKET_BAD)) {
if(!data->req.authneg && (conn->writesockfd != CURL_SOCKET_BAD)) {
data->state.rewindbeforesend = TRUE;
infof(data, "Rewind stream before next send");
}
@ -517,7 +517,7 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
there is just a little (<2K) data left to send, keep on sending. */
/* rewind data when completely done sending! */
if(!conn->bits.authneg && (conn->writesockfd != CURL_SOCKET_BAD)) {
if(!data->req.authneg && (conn->writesockfd != CURL_SOCKET_BAD)) {
data->state.rewindbeforesend = TRUE;
infof(data, "Rewind stream before next send");
}
@ -579,7 +579,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
if((data->state.aptr.user || data->set.str[STRING_BEARER]) &&
((data->req.httpcode == 401) ||
(conn->bits.authneg && data->req.httpcode < 300))) {
(data->req.authneg && data->req.httpcode < 300))) {
pickhost = pickoneauth(&data->state.authhost, authmask);
if(!pickhost)
data->state.authproblem = TRUE;
@ -593,7 +593,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
#ifndef CURL_DISABLE_PROXY
if(conn->bits.proxy_user_passwd &&
((data->req.httpcode == 407) ||
(conn->bits.authneg && data->req.httpcode < 300))) {
(data->req.authneg && data->req.httpcode < 300))) {
pickproxy = pickoneauth(&data->state.authproxy,
authmask & ~CURLAUTH_BEARER);
if(!pickproxy)
@ -619,7 +619,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
}
else if((data->req.httpcode < 300) &&
(!data->state.authhost.done) &&
conn->bits.authneg) {
data->req.authneg) {
/* no (known) authentication available,
authentication is not "done" yet and
no authentication seems to be required and
@ -864,10 +864,10 @@ Curl_http_output_auth(struct Curl_easy *data,
(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;
data->req.authneg = TRUE;
}
else
conn->bits.authneg = FALSE;
data->req.authneg = FALSE;
return result;
}
@ -1809,7 +1809,7 @@ CURLcode Curl_dynhds_add_custom(struct Curl_easy *data,
/* this header is sent later */
hd_name_eq(name, namelen, STRCONST("Content-Type:")))
;
else if(conn->bits.authneg &&
else if(data->req.authneg &&
/* while doing auth neg, don't allow the custom length since
we will force length zero then */
hd_name_eq(name, namelen, STRCONST("Content-Length:")))
@ -1955,7 +1955,7 @@ CURLcode Curl_add_custom_headers(struct Curl_easy *data,
/* this header is sent later */
checkprefix("Content-Type:", compare))
;
else if(conn->bits.authneg &&
else if(data->req.authneg &&
/* while doing auth neg, don't allow the custom length since
we will force length zero then */
checkprefix("Content-Length:", compare))
@ -2413,7 +2413,7 @@ CURLcode Curl_http_body(struct Curl_easy *data, struct connectdata *conn,
http->postsize < 0) ||
((data->state.upload || httpreq == HTTPREQ_POST) &&
data->state.infilesize == -1))) {
if(conn->bits.authneg)
if(data->req.authneg)
/* don't enable chunked during auth neg */
;
else if(Curl_use_http_1_1plus(data, conn)) {
@ -2476,13 +2476,13 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
switch(httpreq) {
case HTTPREQ_PUT: /* Let's PUT the data to the server! */
if(conn->bits.authneg)
if(data->req.authneg)
http->postsize = 0;
else
http->postsize = data->state.infilesize;
if((http->postsize != -1) && !data->req.upload_chunky &&
(conn->bits.authneg ||
(data->req.authneg ||
!Curl_checkheaders(data, STRCONST("Content-Length")))) {
/* only add Content-Length if not uploading chunked */
result = Curl_dyn_addf(r, "Content-Length: %" CURL_FORMAT_CURL_OFF_T
@ -2521,7 +2521,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
case HTTPREQ_POST_FORM:
case HTTPREQ_POST_MIME:
/* This is form posting using mime data. */
if(conn->bits.authneg) {
if(data->req.authneg) {
/* nothing to post! */
result = Curl_dyn_addn(r, STRCONST("Content-Length: 0\r\n\r\n"));
if(result)
@ -2602,7 +2602,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
case HTTPREQ_POST:
/* this is the simple POST, using x-www-form-urlencoded style */
if(conn->bits.authneg)
if(data->req.authneg)
http->postsize = 0;
else
/* the size of the post body */
@ -2612,7 +2612,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
we don't upload data chunked, as RFC2616 forbids us to set both
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
if((http->postsize != -1) && !data->req.upload_chunky &&
(conn->bits.authneg ||
(data->req.authneg ||
!Curl_checkheaders(data, STRCONST("Content-Length")))) {
/* we allow replacing this header if not during auth negotiation,
although it isn't very wise to actually set your own */
@ -2708,7 +2708,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
if(result)
return result;
if(data->req.upload_chunky && conn->bits.authneg) {
if(data->req.upload_chunky && data->req.authneg) {
/* Chunky upload is selected and we're negotiating auth still, send
end-of-data only */
result = Curl_dyn_addn(r, (char *)STRCONST("\x30\x0d\x0a\x0d\x0a"));
@ -2723,7 +2723,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
/* set the pointer to mark that we will send the post body using the
read callback, but only if we're not in authenticate negotiation */
if(!conn->bits.authneg)
if(!data->req.authneg)
http->postdata = (char *)&http->postdata;
}
}
@ -4199,7 +4199,7 @@ static CURLcode http_rw_headers(struct Curl_easy *data,
return result;
if(k->httpcode >= 300) {
if((!conn->bits.authneg) && !conn->bits.close &&
if((!data->req.authneg) && !conn->bits.close &&
!data->state.rewindbeforesend) {
/*
* General treatment of errors when about to send data. Including :

View File

@ -527,10 +527,6 @@ struct ConnectBits {
the TCP layer connect */
BIT(retry); /* this connection is about to get closed and then
re-attempted at another connection. */
BIT(authneg); /* TRUE when the auth phase has started, which means
that we are creating a request with an auth header,
but it is not the final request in the auth
negotiation. */
#ifndef CURL_DISABLE_FTP
BIT(ftp_use_epsv); /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
EPSV doesn't work we disable it for the forthcoming
@ -753,6 +749,10 @@ struct SingleRequest {
specific upload buffers. See readmoredata() in http.c
for details. */
BIT(no_body); /* the response has no body */
BIT(authneg); /* TRUE when the auth phase has started, which means
that we are creating a request with an auth header,
but it is not the final request in the auth
negotiation. */
};
/*