mirror of
https://github.com/curl/curl.git
synced 2026-08-25 10:53:37 +03:00
lib: Curl_read/Curl_write clarifications
- replace `Curl_read()`, `Curl_write()` and `Curl_nwrite()` to
clarify when and at what level they operate
- send/recv of transfer related data is now done via
`Curl_xfer_send()/Curl_xfer_recv()` which no longer has
socket/socketindex as parameter. It decides on the transfer
setup of `conn->sockfd` and `conn->writesockfd` on which
connection filter chain to operate.
- send/recv on a specific connection filter chain is done via
`Curl_conn_send()/Curl_conn_recv()` which get the socket index
as parameter.
- rename `Curl_setup_transfer()` to `Curl_xfer_setup()` for
naming consistency
- clarify that the special CURLE_AGAIN hangling to return
`CURLE_OK` with length 0 only applies to `Curl_xfer_send()`
and CURLE_AGAIN is returned by all other send() variants.
- fix a bug in websocket `curl_ws_recv()` that mixed up data
when it arrived in more than a single chunk (to be made
into a sperate PR, also)
Added as documented [in
CLIENT-READER.md](5b1f31dfba/docs/CLIENT-READERS.md).
- old `Curl_buffer_send()` completely replaced by new `Curl_req_send()`
- old `Curl_fillreadbuffer()` replaced with `Curl_client_read()`
- HTTP chunked uploads are now formatted in a client reader added when
needed.
- FTP line-end conversions are done in a client reader added when
needed.
- when sending requests headers, remaining buffer space is filled with
body data for sending in "one go". This is independent of the request
body size. Resolves #12938 as now small and large requests have the
same code path.
Changes done to test cases:
- test513: now fails before sending request headers as this initial
"client read" triggers the setup fault. Behaves now the same as in
hyper build
- test547, test555, test1620: fix the length check in the lib code to
only fail for reads *smaller* than expected. This was a bug in the
test code that never triggered in the old implementation.
Closes #12969
This commit is contained in:
parent
8d67c61c47
commit
9369c30cd8
26 changed files with 1191 additions and 1021 deletions
12
lib/file.c
12
lib/file.c
|
|
@ -293,10 +293,10 @@ static CURLcode file_upload(struct Curl_easy *data)
|
|||
CURLcode result = CURLE_OK;
|
||||
char *xfer_buf;
|
||||
size_t xfer_blen;
|
||||
char *uphere_save;
|
||||
curl_off_t bytecount = 0;
|
||||
struct_stat file_stat;
|
||||
const char *sendbuf;
|
||||
bool eos = FALSE;
|
||||
|
||||
/*
|
||||
* Since FILE: doesn't do the full init, we need to provide some extra
|
||||
|
|
@ -340,21 +340,16 @@ static CURLcode file_upload(struct Curl_easy *data)
|
|||
data->state.resume_from = (curl_off_t)file_stat.st_size;
|
||||
}
|
||||
|
||||
/* Yikes! Curl_fillreadbuffer uses data->req.upload_fromhere to READ
|
||||
* client data to! Please, someone fix... */
|
||||
uphere_save = data->req.upload_fromhere;
|
||||
|
||||
result = Curl_multi_xfer_buf_borrow(data, &xfer_buf, &xfer_blen);
|
||||
if(result)
|
||||
goto out;
|
||||
|
||||
while(!result) {
|
||||
while(!result && !eos) {
|
||||
size_t nread;
|
||||
ssize_t nwrite;
|
||||
size_t readcount;
|
||||
|
||||
data->req.upload_fromhere = xfer_buf;
|
||||
result = Curl_fillreadbuffer(data, xfer_blen, &readcount);
|
||||
result = Curl_client_read(data, xfer_buf, xfer_blen, &readcount, &eos);
|
||||
if(result)
|
||||
break;
|
||||
|
||||
|
|
@ -401,7 +396,6 @@ static CURLcode file_upload(struct Curl_easy *data)
|
|||
out:
|
||||
close(fd);
|
||||
Curl_multi_xfer_buf_release(data, xfer_buf);
|
||||
data->req.upload_fromhere = uphere_save;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue