Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Rework, Part 1 #12964

Closed
wants to merge 12 commits into from
Closed

Send Rework, Part 1 #12964

wants to merge 12 commits into from

Conversation

icing
Copy link
Contributor

@icing icing commented Feb 19, 2024

This is the second part of reworking curl's "send" or "upload" handling. The changes will arrive in a series of PRs, based on top of each other, similar to the client writer ones. For Part 0 see #12963.

Curl_req_send()

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.

ssize_t args to size_t

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.

@github-actions github-actions bot added the tests label Feb 19, 2024
@icing icing force-pushed the send-part-1 branch 2 times, most recently from 6ec9460 to 62d7054 Compare February 20, 2024 15:19
@icing icing mentioned this pull request Feb 21, 2024
@icing icing force-pushed the send-part-1 branch 2 times, most recently from 02fd6f5 to 280a49a Compare February 26, 2024 15:34
- 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)
- hyper's send/receive callbacks operate on the connection
  (thus needing a socket index) and not on the transport layer
- this fixes the bug that a FTP data connection over http proxy
  was sending on socket TWO, but receiving on socket ONE
  (as the transfer does).
- 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)
- future replacemnt for Curl_buffer_send()
- enabled for GETs

- changed ssize_t to size_t in several functions reading
  data with a CURLcode result. Saves many type conversions
  when checking the lengths
- Curl_buffer_send to static buffer_send
- Curl_req_send_hds as macro using Curl_req_send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

1 participant