url: alloc the download buffer at transfer start

... and free it as soon as the transfer is done. It removes the extra
alloc when a new size is set with setopt() and reduces memory for unused
easy handles.

In addition: the closure_handle now doesn't use an allocated buffer at
all but the smallest supported size as a stack based one.

Closes #5472
This commit is contained in:
Daniel Stenberg 2020-05-28 18:30:47 +02:00
parent 842f73de58
commit c4e6968127
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 66 additions and 105 deletions

View file

@ -258,15 +258,14 @@ static unsigned int http2_conncheck(struct connectdata *check,
void Curl_http2_setup_req(struct Curl_easy *data)
{
struct HTTP *http = data->req.protop;
http->bodystarted = FALSE;
http->status_code = -1;
http->pausedata = NULL;
http->pauselen = 0;
http->closed = FALSE;
http->close_handled = FALSE;
http->mem = data->state.buffer;
http->len = data->set.buffer_size;
http->mem = NULL;
http->len = 0;
http->memlen = 0;
}
@ -2103,6 +2102,8 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
struct http_conn *httpc = &conn->proto.httpc;
struct HTTP *stream = conn->data->req.protop;
DEBUGASSERT(conn->data->state.buffer);
stream->stream_id = -1;
Curl_dyn_init(&stream->header_recvbuf, DYN_H2_HEADERS);
@ -2126,6 +2127,8 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
stream->upload_left = 0;
stream->upload_mem = NULL;
stream->upload_len = 0;
stream->mem = conn->data->state.buffer;
stream->len = conn->data->set.buffer_size;
httpc->inbuflen = 0;
httpc->nread_inbuf = 0;