mirror of
https://github.com/curl/curl.git
synced 2026-08-25 20:13:35 +03:00
http: expect 100 rework
Move all handling of HTTP's `Expect: 100-continue` feature into a client reader. Add sending flag `KEEP_SEND_TIMED` that triggers transfer sending on general events like a timer. HTTP installs a `CURL_CR_PROTOCOL` reader when announcing `Expect: 100-continue`. That reader works as follows: - on first invocation, records time, starts the `EXPIRE_100_TIMEOUT` timer, disables `KEEP_SEND`, enables `KEEP_SEND_TIMER` and returns 0, eos=FALSE like a paused upload. - on subsequent invocation it checks if the timer has expired. If so, it enables `KEEP_SEND` and switches to passing through reads to the underlying readers. Transfer handling's `readwrite()` will be invoked when a timer expires (like `EXPIRE_100_TIMEOUT`) or when data from the server arrives. Seeing `KEEP_SEND_TIMER`, it will try to upload more data, which triggers reading from the client readers again. Which then may lead to a new pausing or cause the upload to start. Flags and timestamps connected to this have been moved from `SingleRequest` into the reader's context. Closes #13110
This commit is contained in:
parent
3d0fd382a2
commit
80a3b830cc
17 changed files with 301 additions and 189 deletions
33
lib/sendf.c
33
lib/sendf.c
|
|
@ -579,6 +579,14 @@ CURLcode Curl_creader_def_unpause(struct Curl_easy *data,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
void Curl_creader_def_done(struct Curl_easy *data,
|
||||
struct Curl_creader *reader, int premature)
|
||||
{
|
||||
(void)data;
|
||||
(void)reader;
|
||||
(void)premature;
|
||||
}
|
||||
|
||||
struct cr_in_ctx {
|
||||
struct Curl_creader super;
|
||||
curl_read_callback read_cb;
|
||||
|
|
@ -840,6 +848,7 @@ static const struct Curl_crtype cr_in = {
|
|||
cr_in_resume_from,
|
||||
cr_in_rewind,
|
||||
Curl_creader_def_unpause,
|
||||
Curl_creader_def_done,
|
||||
sizeof(struct cr_in_ctx)
|
||||
};
|
||||
|
||||
|
|
@ -990,6 +999,7 @@ static const struct Curl_crtype cr_lc = {
|
|||
Curl_creader_def_resume_from,
|
||||
Curl_creader_def_rewind,
|
||||
Curl_creader_def_unpause,
|
||||
Curl_creader_def_done,
|
||||
sizeof(struct cr_lc_ctx)
|
||||
};
|
||||
|
||||
|
|
@ -1154,6 +1164,7 @@ static const struct Curl_crtype cr_null = {
|
|||
Curl_creader_def_resume_from,
|
||||
Curl_creader_def_rewind,
|
||||
Curl_creader_def_unpause,
|
||||
Curl_creader_def_done,
|
||||
sizeof(struct Curl_creader)
|
||||
};
|
||||
|
||||
|
|
@ -1250,6 +1261,7 @@ static const struct Curl_crtype cr_buf = {
|
|||
cr_buf_resume_from,
|
||||
Curl_creader_def_rewind,
|
||||
Curl_creader_def_unpause,
|
||||
Curl_creader_def_done,
|
||||
sizeof(struct cr_buf_ctx)
|
||||
};
|
||||
|
||||
|
|
@ -1307,3 +1319,24 @@ CURLcode Curl_creader_unpause(struct Curl_easy *data)
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Curl_creader_done(struct Curl_easy *data, int premature)
|
||||
{
|
||||
struct Curl_creader *reader = data->req.reader_stack;
|
||||
while(reader) {
|
||||
reader->crt->done(data, reader, premature);
|
||||
reader = reader->next;
|
||||
}
|
||||
}
|
||||
|
||||
struct Curl_creader *Curl_creader_get_by_type(struct Curl_easy *data,
|
||||
const struct Curl_crtype *crt)
|
||||
{
|
||||
struct Curl_creader *r;
|
||||
for(r = data->req.reader_stack; r; r = r->next) {
|
||||
if(r->crt == crt)
|
||||
return r;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue