diff options
Diffstat (limited to 'libs/libcurl/src/request.c')
-rw-r--r-- | libs/libcurl/src/request.c | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/libs/libcurl/src/request.c b/libs/libcurl/src/request.c index 66130d3f1d..9b11fa2aec 100644 --- a/libs/libcurl/src/request.c +++ b/libs/libcurl/src/request.c @@ -26,7 +26,7 @@ #include "urldata.h"
#include "cfilters.h"
-#include "dynbuf.h"
+#include "curlx/dynbuf.h"
#include "doh.h"
#include "multiif.h"
#include "progress.h"
@@ -34,6 +34,7 @@ #include "sendf.h"
#include "transfer.h"
#include "url.h"
+#include "curlx/strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -66,6 +67,9 @@ CURLcode Curl_req_soft_reset(struct SingleRequest *req, req->headerbytecount = 0;
req->allheadercount = 0;
req->deductheadercount = 0;
+ req->httpversion_sent = 0;
+ req->httpversion = 0;
+ req->sendbuf_hds_len = 0;
result = Curl_client_start(data);
if(result)
@@ -91,7 +95,7 @@ CURLcode Curl_req_soft_reset(struct SingleRequest *req, CURLcode Curl_req_start(struct SingleRequest *req,
struct Curl_easy *data)
{
- req->start = Curl_now();
+ req->start = curlx_now();
return Curl_req_soft_reset(req, data);
}
@@ -114,9 +118,6 @@ void Curl_req_hard_reset(struct SingleRequest *req, struct Curl_easy *data) {
struct curltime t0 = {0, 0};
- /* This is a bit ugly. `req->p` is a union and we assume we can
- * free this safely without leaks. */
- Curl_safefree(req->p.ftp);
Curl_safefree(req->newurl);
Curl_client_reset(data);
if(req->sendbuf_init)
@@ -139,6 +140,7 @@ void Curl_req_hard_reset(struct SingleRequest *req, struct Curl_easy *data) req->httpcode = 0;
req->keepon = 0;
req->upgr101 = UPGR101_INIT;
+ req->sendbuf_hds_len = 0;
req->timeofdoc = 0;
req->location = NULL;
req->newurl = NULL;
@@ -162,24 +164,14 @@ void Curl_req_hard_reset(struct SingleRequest *req, struct Curl_easy *data) req->no_body = data->set.opt_no_body;
req->authneg = FALSE;
req->shutdown = FALSE;
-#ifdef USE_HYPER
- req->bodywritten = FALSE;
-#endif
}
void Curl_req_free(struct SingleRequest *req, struct Curl_easy *data)
{
- /* This is a bit ugly. `req->p` is a union and we assume we can
- * free this safely without leaks. */
- Curl_safefree(req->p.ftp);
Curl_safefree(req->newurl);
if(req->sendbuf_init)
Curl_bufq_free(&req->sendbuf);
Curl_client_cleanup(data);
-
-#ifndef CURL_DISABLE_DOH
- Curl_doh_cleanup(data);
-#endif
}
static CURLcode xfer_send(struct Curl_easy *data,
@@ -196,11 +188,13 @@ static CURLcode xfer_send(struct Curl_easy *data, /* Allow debug builds to override this logic to force short initial
sends */
size_t body_len = blen - hds_len;
- char *p = getenv("CURL_SMALLREQSEND");
- if(p) {
- size_t body_small = (size_t)strtoul(p, NULL, 10);
- if(body_small && body_small < body_len)
- blen = hds_len + body_small;
+ if(body_len) {
+ const char *p = getenv("CURL_SMALLREQSEND");
+ if(p) {
+ curl_off_t body_small;
+ if(!curlx_str_number(&p, &body_small, body_len))
+ blen = hds_len + (size_t)body_small;
+ }
}
}
#endif
@@ -224,11 +218,11 @@ static CURLcode xfer_send(struct Curl_easy *data, data->req.eos_sent = TRUE;
if(*pnwritten) {
if(hds_len)
- Curl_debug(data, CURLINFO_HEADER_OUT, (char *)buf,
+ Curl_debug(data, CURLINFO_HEADER_OUT, buf,
CURLMIN(hds_len, *pnwritten));
if(*pnwritten > hds_len) {
size_t body_len = *pnwritten - hds_len;
- Curl_debug(data, CURLINFO_DATA_OUT, (char *)buf + hds_len, body_len);
+ Curl_debug(data, CURLINFO_DATA_OUT, buf + hds_len, body_len);
data->req.writebytecount += body_len;
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
}
@@ -261,7 +255,7 @@ static CURLcode req_send_buffer_flush(struct Curl_easy *data) return result;
}
-CURLcode Curl_req_set_upload_done(struct Curl_easy *data)
+static CURLcode req_set_upload_done(struct Curl_easy *data)
{
DEBUGASSERT(!data->req.upload_done);
data->req.upload_done = TRUE;
@@ -339,7 +333,7 @@ static CURLcode req_flush(struct Curl_easy *data) if(!done)
return CURLE_AGAIN;
}
- return Curl_req_set_upload_done(data);
+ return req_set_upload_done(data);
}
return CURLE_OK;
}
@@ -360,8 +354,6 @@ static ssize_t add_from_client(void *reader_ctx, return (ssize_t)nread;
}
-#ifndef USE_HYPER
-
static CURLcode req_send_buffer_add(struct Curl_easy *data,
const char *buf, size_t blen,
size_t hds_len)
@@ -378,7 +370,8 @@ static CURLcode req_send_buffer_add(struct Curl_easy *data, return CURLE_OK;
}
-CURLcode Curl_req_send(struct Curl_easy *data, struct dynbuf *req)
+CURLcode Curl_req_send(struct Curl_easy *data, struct dynbuf *req,
+ unsigned char httpversion)
{
CURLcode result;
const char *buf;
@@ -387,8 +380,9 @@ CURLcode Curl_req_send(struct Curl_easy *data, struct dynbuf *req) if(!data || !data->conn)
return CURLE_FAILED_INIT;
- buf = Curl_dyn_ptr(req);
- blen = Curl_dyn_len(req);
+ data->req.httpversion_sent = httpversion;
+ buf = curlx_dyn_ptr(req);
+ blen = curlx_dyn_len(req);
if(!Curl_creader_total_length(data)) {
/* Request without body. Try to send directly from the buf given. */
data->req.eos_read = TRUE;
@@ -411,7 +405,6 @@ CURLcode Curl_req_send(struct Curl_easy *data, struct dynbuf *req) }
return CURLE_OK;
}
-#endif /* !USE_HYPER */
bool Curl_req_sendbuf_empty(struct Curl_easy *data)
{
@@ -464,7 +457,7 @@ CURLcode Curl_req_abort_sending(struct Curl_easy *data) data->req.upload_aborted = TRUE;
/* no longer KEEP_SEND and KEEP_SEND_PAUSE */
data->req.keepon &= ~KEEP_SENDBITS;
- return Curl_req_set_upload_done(data);
+ return req_set_upload_done(data);
}
return CURLE_OK;
}
|