summaryrefslogtreecommitdiff
path: root/lib/c-hyper.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-08 17:58:15 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-17 23:56:09 +0100
commit215db086e09665ee7af9b646ad6c4d6e281001ac (patch)
tree50c74f8456df87e86de6d72e90190a3563083a1a /lib/c-hyper.c
parent0d26ab9ed3ac29da2a383d313e93df3e9f5295a2 (diff)
downloadcurl-215db086e09665ee7af9b646ad6c4d6e281001ac.tar.gz
lib: pass in 'struct Curl_easy *' to most functions
... in most cases instead of 'struct connectdata *' but in some cases in addition to. - We mostly operate on transfers and not connections. - We need the transfer handle to log, store data and more. Everything in libcurl is driven by a transfer (the CURL * in the public API). - This work clarifies and separates the transfers from the connections better. - We should avoid "conn->data". Since individual connections can be used by many transfers when multiplexing, making sure that conn->data points to the current and correct transfer at all times is difficult and has been notoriously error-prone over the years. The goal is to ultimately remove the conn->data pointer for this reason. Closes #6425
Diffstat (limited to 'lib/c-hyper.c')
-rw-r--r--lib/c-hyper.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/c-hyper.c b/lib/c-hyper.c
index 4a68ffba0..91c1f7a2d 100644
--- a/lib/c-hyper.c
+++ b/lib/c-hyper.c
@@ -67,7 +67,7 @@ size_t Curl_hyper_recv(void *userp, hyper_context *ctx,
(void)ctx;
- result = Curl_read(conn, conn->sockfd, (char *)buf, buflen, &nread);
+ result = Curl_read(data, conn->sockfd, (char *)buf, buflen, &nread);
if(result == CURLE_AGAIN) {
/* would block, register interest */
if(data->hyp.read_waker)
@@ -94,7 +94,7 @@ size_t Curl_hyper_send(void *userp, hyper_context *ctx,
CURLcode result;
ssize_t nwrote;
- result = Curl_write(conn, conn->sockfd, (void *)buf, buflen, &nwrote);
+ result = Curl_write(data, conn->sockfd, (void *)buf, buflen, &nwrote);
if(result == CURLE_AGAIN) {
/* would block, register interest */
if(data->hyp.write_waker)
@@ -380,7 +380,7 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data,
/* Curl_http_auth_act() checks what authentication methods that are
* available and decides which one (if any) to use. It will set 'newurl'
* if an auth method was picked. */
- result = Curl_http_auth_act(conn);
+ result = Curl_http_auth_act(data);
if(result)
break;
@@ -628,9 +628,9 @@ static CURLcode cookies(struct Curl_easy *data,
* request is to be performed. This creates and sends a properly constructed
* HTTP request.
*/
-CURLcode Curl_http(struct connectdata *conn, bool *done)
+CURLcode Curl_http(struct Curl_easy *data, bool *done)
{
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
struct hyptransfer *h = &data->hyp;
hyper_io *io = NULL;
hyper_clientconn_options *options = NULL;
@@ -670,7 +670,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(!pq)
return CURLE_OUT_OF_MEMORY;
}
- result = Curl_http_output_auth(conn, method, httpreq,
+ result = Curl_http_output_auth(data, conn, method, httpreq,
(pq ? pq : data->state.up.path), FALSE);
free(pq);
if(result)
@@ -681,11 +681,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(result)
return result;
- result = Curl_http_range(data, conn, httpreq);
+ result = Curl_http_range(data, httpreq);
if(result)
return result;
- result = Curl_http_useragent(data, conn);
+ result = Curl_http_useragent(data);
if(result)
return result;
@@ -799,7 +799,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_hyper_header(data, headers, data->state.aptr.uagent))
goto error;
- p_accept = Curl_checkheaders(conn, "Accept")?NULL:"Accept: */*\r\n";
+ p_accept = Curl_checkheaders(data, "Accept")?NULL:"Accept: */*\r\n";
if(p_accept && Curl_hyper_header(data, headers, p_accept))
goto error;
@@ -808,14 +808,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy &&
- !Curl_checkProxyheaders(conn, "Proxy-Connection")) {
+ !Curl_checkProxyheaders(data, conn, "Proxy-Connection")) {
if(Curl_hyper_header(data, headers, "Proxy-Connection: Keep-Alive"))
goto error;
}
#endif
Curl_safefree(data->state.aptr.ref);
- if(data->change.referer && !Curl_checkheaders(conn, "Referer")) {
+ if(data->change.referer && !Curl_checkheaders(data, "Referer")) {
data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
if(!data->state.aptr.ref)
return CURLE_OUT_OF_MEMORY;
@@ -827,11 +827,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(result)
return result;
- result = Curl_add_timecondition(conn, headers);
+ result = Curl_add_timecondition(data, headers);
if(result)
return result;
- result = Curl_add_custom_headers(conn, FALSE, headers);
+ result = Curl_add_custom_headers(data, FALSE, headers);
if(result)
return result;