2024-02-14 19:09:32 +08:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
|
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: curl
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "curl_setup.h"
|
|
|
|
|
|
|
|
#include "urldata.h"
|
2024-02-28 21:51:53 +08:00
|
|
|
#include "cfilters.h"
|
2024-02-14 19:09:32 +08:00
|
|
|
#include "dynbuf.h"
|
|
|
|
#include "doh.h"
|
2024-02-15 23:22:53 +08:00
|
|
|
#include "multiif.h"
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
#include "progress.h"
|
2024-02-14 19:09:32 +08:00
|
|
|
#include "request.h"
|
|
|
|
#include "sendf.h"
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
#include "transfer.h"
|
2024-02-14 19:09:32 +08:00
|
|
|
#include "url.h"
|
|
|
|
|
|
|
|
/* The last 3 #include files should be in this order */
|
|
|
|
#include "curl_printf.h"
|
|
|
|
#include "curl_memory.h"
|
|
|
|
#include "memdebug.h"
|
|
|
|
|
2024-04-19 16:46:42 +08:00
|
|
|
void Curl_req_init(struct SingleRequest *req)
|
2024-02-14 19:09:32 +08:00
|
|
|
{
|
|
|
|
memset(req, 0, sizeof(*req));
|
|
|
|
}
|
|
|
|
|
2024-03-11 19:35:07 +08:00
|
|
|
CURLcode Curl_req_soft_reset(struct SingleRequest *req,
|
|
|
|
struct Curl_easy *data)
|
2024-02-14 19:09:32 +08:00
|
|
|
{
|
2024-02-29 17:12:39 +08:00
|
|
|
CURLcode result;
|
|
|
|
|
2024-03-11 19:35:07 +08:00
|
|
|
req->done = FALSE;
|
|
|
|
req->upload_done = FALSE;
|
|
|
|
req->download_done = FALSE;
|
|
|
|
req->ignorebody = FALSE;
|
2024-06-10 19:32:13 +08:00
|
|
|
req->shutdown = FALSE;
|
2024-03-11 19:35:07 +08:00
|
|
|
req->bytecount = 0;
|
|
|
|
req->writebytecount = 0;
|
|
|
|
req->header = TRUE; /* assume header */
|
|
|
|
req->headerline = 0;
|
|
|
|
req->headerbytecount = 0;
|
|
|
|
req->allheadercount = 0;
|
|
|
|
req->deductheadercount = 0;
|
|
|
|
|
2024-02-29 17:12:39 +08:00
|
|
|
result = Curl_client_start(data);
|
|
|
|
if(result)
|
|
|
|
return result;
|
|
|
|
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
if(!req->sendbuf_init) {
|
|
|
|
Curl_bufq_init2(&req->sendbuf, data->set.upload_buffer_size, 1,
|
|
|
|
BUFQ_OPT_SOFT_LIMIT);
|
|
|
|
req->sendbuf_init = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Curl_bufq_reset(&req->sendbuf);
|
|
|
|
if(data->set.upload_buffer_size != req->sendbuf.chunk_size) {
|
|
|
|
Curl_bufq_free(&req->sendbuf);
|
|
|
|
Curl_bufq_init2(&req->sendbuf, data->set.upload_buffer_size, 1,
|
|
|
|
BUFQ_OPT_SOFT_LIMIT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-14 19:09:32 +08:00
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2024-03-11 19:35:07 +08:00
|
|
|
CURLcode Curl_req_start(struct SingleRequest *req,
|
|
|
|
struct Curl_easy *data)
|
|
|
|
{
|
|
|
|
req->start = Curl_now();
|
|
|
|
return Curl_req_soft_reset(req, data);
|
|
|
|
}
|
|
|
|
|
2024-02-28 21:51:53 +08:00
|
|
|
static CURLcode req_flush(struct Curl_easy *data);
|
|
|
|
|
2024-02-14 19:09:32 +08:00
|
|
|
CURLcode Curl_req_done(struct SingleRequest *req,
|
|
|
|
struct Curl_easy *data, bool aborted)
|
|
|
|
{
|
|
|
|
(void)req;
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
if(!aborted)
|
2024-02-28 21:51:53 +08:00
|
|
|
(void)req_flush(data);
|
2024-02-15 23:22:53 +08:00
|
|
|
Curl_client_reset(data);
|
2024-08-12 17:28:19 +08:00
|
|
|
#ifndef CURL_DISABLE_DOH
|
|
|
|
Curl_doh_close(data);
|
|
|
|
#endif
|
2024-02-14 19:09:32 +08:00
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2024-03-11 19:35:07 +08:00
|
|
|
void Curl_req_hard_reset(struct SingleRequest *req, struct Curl_easy *data)
|
2024-02-14 19:09:32 +08:00
|
|
|
{
|
2024-02-29 17:12:39 +08:00
|
|
|
struct curltime t0 = {0, 0};
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
|
2024-02-14 19:09:32 +08:00
|
|
|
/* This is a bit ugly. `req->p` is a union and we assume we can
|
|
|
|
* free this safely without leaks. */
|
2024-06-12 17:05:44 +08:00
|
|
|
Curl_safefree(req->p.ftp);
|
2024-02-14 19:09:32 +08:00
|
|
|
Curl_safefree(req->newurl);
|
2024-02-15 23:22:53 +08:00
|
|
|
Curl_client_reset(data);
|
2024-02-29 17:12:39 +08:00
|
|
|
if(req->sendbuf_init)
|
|
|
|
Curl_bufq_reset(&req->sendbuf);
|
2024-02-14 19:09:32 +08:00
|
|
|
|
|
|
|
#ifndef CURL_DISABLE_DOH
|
2024-07-17 20:46:47 +08:00
|
|
|
Curl_doh_close(data);
|
2024-02-14 19:09:32 +08:00
|
|
|
#endif
|
2024-02-29 17:12:39 +08:00
|
|
|
/* Can no longer memset() this struct as we need to keep some state */
|
|
|
|
req->size = -1;
|
|
|
|
req->maxdownload = -1;
|
|
|
|
req->bytecount = 0;
|
|
|
|
req->writebytecount = 0;
|
|
|
|
req->start = t0;
|
|
|
|
req->headerbytecount = 0;
|
|
|
|
req->allheadercount = 0;
|
|
|
|
req->deductheadercount = 0;
|
|
|
|
req->headerline = 0;
|
|
|
|
req->offset = 0;
|
|
|
|
req->httpcode = 0;
|
|
|
|
req->keepon = 0;
|
|
|
|
req->upgr101 = UPGR101_INIT;
|
|
|
|
req->timeofdoc = 0;
|
|
|
|
req->location = NULL;
|
|
|
|
req->newurl = NULL;
|
|
|
|
#ifndef CURL_DISABLE_COOKIES
|
|
|
|
req->setcookies = 0;
|
|
|
|
#endif
|
|
|
|
req->header = FALSE;
|
|
|
|
req->content_range = FALSE;
|
|
|
|
req->download_done = FALSE;
|
|
|
|
req->eos_written = FALSE;
|
|
|
|
req->eos_read = FALSE;
|
|
|
|
req->upload_done = FALSE;
|
|
|
|
req->upload_aborted = FALSE;
|
|
|
|
req->ignorebody = FALSE;
|
|
|
|
req->http_bodyless = FALSE;
|
|
|
|
req->chunk = FALSE;
|
|
|
|
req->ignore_cl = FALSE;
|
|
|
|
req->upload_chunky = FALSE;
|
|
|
|
req->getheader = FALSE;
|
|
|
|
req->no_body = data->set.opt_no_body;
|
|
|
|
req->authneg = FALSE;
|
2024-06-10 19:32:13 +08:00
|
|
|
req->shutdown = FALSE;
|
2024-06-12 17:20:00 +08:00
|
|
|
#ifdef USE_HYPER
|
|
|
|
req->bodywritten = FALSE;
|
|
|
|
#endif
|
2024-02-14 19:09:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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. */
|
2024-06-12 17:05:44 +08:00
|
|
|
Curl_safefree(req->p.ftp);
|
2024-02-14 19:09:32 +08:00
|
|
|
Curl_safefree(req->newurl);
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
if(req->sendbuf_init)
|
|
|
|
Curl_bufq_free(&req->sendbuf);
|
2024-02-29 17:12:39 +08:00
|
|
|
Curl_client_cleanup(data);
|
2024-02-14 19:09:32 +08:00
|
|
|
|
|
|
|
#ifndef CURL_DISABLE_DOH
|
2024-07-17 20:46:47 +08:00
|
|
|
Curl_doh_cleanup(data);
|
2024-02-14 19:09:32 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2024-02-28 21:51:53 +08:00
|
|
|
static CURLcode xfer_send(struct Curl_easy *data,
|
|
|
|
const char *buf, size_t blen,
|
|
|
|
size_t hds_len, size_t *pnwritten)
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
{
|
|
|
|
CURLcode result = CURLE_OK;
|
2024-07-18 17:29:37 +08:00
|
|
|
bool eos = FALSE;
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
|
|
|
|
*pnwritten = 0;
|
2024-08-07 18:42:27 +08:00
|
|
|
DEBUGASSERT(hds_len <= blen);
|
2024-05-20 20:21:05 +08:00
|
|
|
#ifdef DEBUGBUILD
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
{
|
|
|
|
/* Allow debug builds to override this logic to force short initial
|
2024-08-07 18:42:27 +08:00
|
|
|
sends */
|
|
|
|
size_t body_len = blen - hds_len;
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
char *p = getenv("CURL_SMALLREQSEND");
|
|
|
|
if(p) {
|
2024-08-07 18:42:27 +08:00
|
|
|
size_t body_small = (size_t)strtoul(p, NULL, 10);
|
|
|
|
if(body_small && body_small < body_len)
|
|
|
|
blen = hds_len + body_small;
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2024-07-01 22:47:21 +08:00
|
|
|
/* Make sure this does not send more body bytes than what the max send
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
speed says. The headers do not count to the max speed. */
|
|
|
|
if(data->set.max_send_speed) {
|
|
|
|
size_t body_bytes = blen - hds_len;
|
|
|
|
if((curl_off_t)body_bytes > data->set.max_send_speed)
|
|
|
|
blen = hds_len + (size_t)data->set.max_send_speed;
|
|
|
|
}
|
|
|
|
|
2024-07-18 17:29:37 +08:00
|
|
|
if(data->req.eos_read &&
|
|
|
|
(Curl_bufq_is_empty(&data->req.sendbuf) ||
|
|
|
|
Curl_bufq_len(&data->req.sendbuf) == blen)) {
|
|
|
|
DEBUGF(infof(data, "sending last upload chunk of %zu bytes", blen));
|
|
|
|
eos = TRUE;
|
|
|
|
}
|
|
|
|
result = Curl_xfer_send(data, buf, blen, eos, pnwritten);
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
if(!result && *pnwritten) {
|
|
|
|
if(hds_len)
|
|
|
|
Curl_debug(data, CURLINFO_HEADER_OUT, (char *)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);
|
|
|
|
data->req.writebytecount += body_len;
|
|
|
|
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CURLcode req_send_buffer_flush(struct Curl_easy *data)
|
|
|
|
{
|
|
|
|
CURLcode result = CURLE_OK;
|
|
|
|
const unsigned char *buf;
|
|
|
|
size_t blen;
|
|
|
|
|
|
|
|
while(Curl_bufq_peek(&data->req.sendbuf, &buf, &blen)) {
|
|
|
|
size_t nwritten, hds_len = CURLMIN(data->req.sendbuf_hds_len, blen);
|
2024-02-28 21:51:53 +08:00
|
|
|
result = xfer_send(data, (const char *)buf, blen, hds_len, &nwritten);
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
if(result)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Curl_bufq_skip(&data->req.sendbuf, nwritten);
|
2024-02-15 23:22:53 +08:00
|
|
|
if(hds_len) {
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
data->req.sendbuf_hds_len -= CURLMIN(hds_len, nwritten);
|
2024-02-15 23:22:53 +08: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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
/* leave if we could not send all. Maybe network blocking or
|
|
|
|
* speed limits on transfer */
|
|
|
|
if(nwritten < blen)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-08-14 16:22:20 +08:00
|
|
|
CURLcode Curl_req_set_upload_done(struct Curl_easy *data)
|
2024-02-28 21:51:53 +08:00
|
|
|
{
|
|
|
|
DEBUGASSERT(!data->req.upload_done);
|
|
|
|
data->req.upload_done = TRUE;
|
2024-07-01 22:47:21 +08:00
|
|
|
data->req.keepon &= ~(KEEP_SEND|KEEP_SEND_TIMED); /* we are done sending */
|
2024-02-28 21:51:53 +08:00
|
|
|
|
2024-07-15 16:52:50 +08:00
|
|
|
Curl_pgrsTime(data, TIMER_POSTRANSFER);
|
2024-03-12 00:23:15 +08:00
|
|
|
Curl_creader_done(data, data->req.upload_aborted);
|
2024-02-28 21:51:53 +08:00
|
|
|
|
|
|
|
if(data->req.upload_aborted) {
|
2024-07-25 19:10:01 +08:00
|
|
|
Curl_bufq_reset(&data->req.sendbuf);
|
2024-02-28 21:51:53 +08:00
|
|
|
if(data->req.writebytecount)
|
|
|
|
infof(data, "abort upload after having sent %" CURL_FORMAT_CURL_OFF_T
|
|
|
|
" bytes", data->req.writebytecount);
|
|
|
|
else
|
|
|
|
infof(data, "abort upload");
|
|
|
|
}
|
|
|
|
else if(data->req.writebytecount)
|
|
|
|
infof(data, "upload completely sent off: %" CURL_FORMAT_CURL_OFF_T
|
|
|
|
" bytes", data->req.writebytecount);
|
2024-08-07 18:42:27 +08:00
|
|
|
else if(!data->req.download_done) {
|
|
|
|
DEBUGASSERT(Curl_bufq_is_empty(&data->req.sendbuf));
|
2024-03-11 16:50:55 +08:00
|
|
|
infof(data, Curl_creader_total_length(data)?
|
|
|
|
"We are completely uploaded and fine" :
|
|
|
|
"Request completely sent off");
|
2024-08-07 18:42:27 +08:00
|
|
|
}
|
2024-02-28 21:51:53 +08:00
|
|
|
|
|
|
|
return Curl_xfer_send_close(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CURLcode req_flush(struct Curl_easy *data)
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
{
|
|
|
|
CURLcode result;
|
|
|
|
|
|
|
|
if(!data || !data->conn)
|
|
|
|
return CURLE_FAILED_INIT;
|
|
|
|
|
|
|
|
if(!Curl_bufq_is_empty(&data->req.sendbuf)) {
|
|
|
|
result = req_send_buffer_flush(data);
|
|
|
|
if(result)
|
|
|
|
return result;
|
|
|
|
if(!Curl_bufq_is_empty(&data->req.sendbuf)) {
|
2024-07-25 19:10:01 +08:00
|
|
|
DEBUGF(infof(data, "Curl_req_flush(len=%zu) -> EAGAIN",
|
|
|
|
Curl_bufq_len(&data->req.sendbuf)));
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
return CURLE_AGAIN;
|
|
|
|
}
|
|
|
|
}
|
2024-07-25 19:10:01 +08:00
|
|
|
else if(Curl_xfer_needs_flush(data)) {
|
|
|
|
DEBUGF(infof(data, "Curl_req_flush(), xfer send_pending"));
|
|
|
|
return Curl_xfer_flush(data);
|
|
|
|
}
|
2024-02-28 21:51:53 +08:00
|
|
|
|
|
|
|
if(!data->req.upload_done && data->req.eos_read &&
|
|
|
|
Curl_bufq_is_empty(&data->req.sendbuf)) {
|
2024-06-10 19:32:13 +08:00
|
|
|
if(data->req.shutdown) {
|
|
|
|
bool done;
|
|
|
|
result = Curl_xfer_send_shutdown(data, &done);
|
|
|
|
if(result)
|
|
|
|
return result;
|
|
|
|
if(!done)
|
|
|
|
return CURLE_AGAIN;
|
|
|
|
}
|
2024-08-14 16:22:20 +08:00
|
|
|
return Curl_req_set_upload_done(data);
|
2024-02-28 21:51:53 +08: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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2024-02-28 21:51:53 +08:00
|
|
|
static ssize_t add_from_client(void *reader_ctx,
|
|
|
|
unsigned char *buf, size_t buflen,
|
|
|
|
CURLcode *err)
|
|
|
|
{
|
|
|
|
struct Curl_easy *data = reader_ctx;
|
|
|
|
size_t nread;
|
|
|
|
bool eos;
|
|
|
|
|
|
|
|
*err = Curl_client_read(data, (char *)buf, buflen, &nread, &eos);
|
|
|
|
if(*err)
|
|
|
|
return -1;
|
|
|
|
if(eos)
|
|
|
|
data->req.eos_read = TRUE;
|
|
|
|
return (ssize_t)nread;
|
|
|
|
}
|
|
|
|
|
2024-02-15 23:22:53 +08:00
|
|
|
#ifndef USE_HYPER
|
|
|
|
|
|
|
|
static CURLcode req_send_buffer_add(struct Curl_easy *data,
|
|
|
|
const char *buf, size_t blen,
|
|
|
|
size_t hds_len)
|
|
|
|
{
|
|
|
|
CURLcode result = CURLE_OK;
|
|
|
|
ssize_t n;
|
|
|
|
n = Curl_bufq_write(&data->req.sendbuf,
|
|
|
|
(const unsigned char *)buf, blen, &result);
|
|
|
|
if(n < 0)
|
|
|
|
return result;
|
|
|
|
/* We rely on a SOFTLIMIT on sendbuf, so it can take all data in */
|
|
|
|
DEBUGASSERT((size_t)n == blen);
|
|
|
|
data->req.sendbuf_hds_len += hds_len;
|
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2024-03-18 19:46:43 +08:00
|
|
|
CURLcode Curl_req_send(struct Curl_easy *data, struct dynbuf *req)
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
{
|
|
|
|
CURLcode result;
|
2024-03-18 19:46:43 +08:00
|
|
|
const char *buf;
|
|
|
|
size_t blen, nwritten;
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
|
|
|
|
if(!data || !data->conn)
|
|
|
|
return CURLE_FAILED_INIT;
|
|
|
|
|
2024-03-18 19:46:43 +08:00
|
|
|
buf = Curl_dyn_ptr(req);
|
|
|
|
blen = Curl_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;
|
|
|
|
result = xfer_send(data, buf, blen, blen, &nwritten);
|
|
|
|
if(result)
|
|
|
|
return result;
|
|
|
|
buf += nwritten;
|
|
|
|
blen -= nwritten;
|
|
|
|
}
|
2024-02-15 23:22:53 +08:00
|
|
|
|
2024-03-18 19:46:43 +08:00
|
|
|
if(blen) {
|
|
|
|
/* Either we have a request body, or we could not send the complete
|
|
|
|
* request in one go. Buffer the remainder and try to add as much
|
|
|
|
* body bytes as room is left in the buffer. Then flush. */
|
|
|
|
result = req_send_buffer_add(data, buf, blen, blen);
|
|
|
|
if(result)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
return Curl_req_send_more(data);
|
|
|
|
}
|
|
|
|
return CURLE_OK;
|
2024-02-28 21:51:53 +08:00
|
|
|
}
|
|
|
|
#endif /* !USE_HYPER */
|
|
|
|
|
2024-07-25 19:10:01 +08:00
|
|
|
bool Curl_req_sendbuf_empty(struct Curl_easy *data)
|
|
|
|
{
|
|
|
|
return !data->req.sendbuf_init || Curl_bufq_is_empty(&data->req.sendbuf);
|
|
|
|
}
|
|
|
|
|
2024-02-28 21:51:53 +08:00
|
|
|
bool Curl_req_want_send(struct Curl_easy *data)
|
|
|
|
{
|
2024-07-25 19:10:01 +08:00
|
|
|
/* Not done and
|
|
|
|
* - KEEP_SEND and not PAUSEd.
|
|
|
|
* - or request has buffered data to send
|
|
|
|
* - or transfer connection has pending data to send */
|
|
|
|
return !data->req.done &&
|
|
|
|
(((data->req.keepon & KEEP_SENDBITS) == KEEP_SEND) ||
|
|
|
|
!Curl_req_sendbuf_empty(data) ||
|
|
|
|
Curl_xfer_needs_flush(data));
|
2024-02-28 21:51:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Curl_req_done_sending(struct Curl_easy *data)
|
|
|
|
{
|
2024-07-25 19:10:01 +08:00
|
|
|
return data->req.upload_done && !Curl_req_want_send(data);
|
2024-02-28 21:51:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CURLcode Curl_req_send_more(struct Curl_easy *data)
|
|
|
|
{
|
|
|
|
CURLcode result;
|
|
|
|
|
2024-03-12 00:23:15 +08:00
|
|
|
/* Fill our send buffer if more from client can be read. */
|
2024-07-25 19:10:01 +08:00
|
|
|
if(!data->req.upload_aborted &&
|
|
|
|
!data->req.eos_read &&
|
|
|
|
!(data->req.keepon & KEEP_SEND_PAUSE) &&
|
|
|
|
!Curl_bufq_is_full(&data->req.sendbuf)) {
|
2024-02-15 23:22:53 +08:00
|
|
|
ssize_t nread = Curl_bufq_sipn(&data->req.sendbuf, 0,
|
|
|
|
add_from_client, data, &result);
|
|
|
|
if(nread < 0 && result != CURLE_AGAIN)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-02-28 21:51:53 +08:00
|
|
|
result = req_flush(data);
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
if(result == CURLE_AGAIN)
|
|
|
|
result = CURLE_OK;
|
2024-04-03 19:18:01 +08: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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-02-28 21:51:53 +08:00
|
|
|
CURLcode Curl_req_abort_sending(struct Curl_easy *data)
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
{
|
2024-02-28 21:51:53 +08:00
|
|
|
if(!data->req.upload_done) {
|
|
|
|
Curl_bufq_reset(&data->req.sendbuf);
|
|
|
|
data->req.upload_aborted = TRUE;
|
2024-07-25 19:10:01 +08:00
|
|
|
/* no longer KEEP_SEND and KEEP_SEND_PAUSE */
|
|
|
|
data->req.keepon &= ~KEEP_SENDBITS;
|
2024-08-14 16:22:20 +08:00
|
|
|
return Curl_req_set_upload_done(data);
|
2024-02-28 21:51:53 +08:00
|
|
|
}
|
|
|
|
return CURLE_OK;
|
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
The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:
* `Curl_req_send()`: has parameter to indicate amount of header bytes,
buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
sent.
In addition there is `Curl_req_flush()` for writing out all buffered
bytes.
`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:
* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
`data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
conversions will be moved into something like a Client Reader.
In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.
Closes #12964
2024-02-15 23:22:53 +08:00
|
|
|
}
|
2024-07-25 19:10:01 +08:00
|
|
|
|
|
|
|
CURLcode Curl_req_stop_send_recv(struct Curl_easy *data)
|
|
|
|
{
|
|
|
|
/* stop receiving and ALL sending as well, including PAUSE and HOLD.
|
|
|
|
* We might still be paused on receive client writes though, so
|
|
|
|
* keep those bits around. */
|
|
|
|
data->req.keepon &= ~(KEEP_RECV|KEEP_SENDBITS);
|
|
|
|
return Curl_req_abort_sending(data);
|
|
|
|
}
|