pushpin icon indicating copy to clipboard operation
pushpin copied to clipboard

connection: use new server module for req mode

Open jkarneges opened this issue 9 months ago • 0 comments

There are connection handlers in src/connection.rs for two different modes of operation: "req" mode for buffered, and "stream" mode for streaming. This PR updates the req mode handler to use the refactored server request module. The stream mode handler still uses the original server request code. The changes are being done in parts to keep the PRs smaller.

The main goal of this work is to be able to send error responses. To centralize our error handling, the req mode handler function (server_req_handler) is split into a few sub-functions. The most notable is server_req_respond, which handles a request all the way up to the point of preparing a response header. On success, a response header has been prepared for the caller to send. On error, a response header has not been prepared, allowing the caller to send an error response instead. We lose the ability to send error responses once we attempt to send a successfully prepared header, and so server_req_respond fully encapsulates all situations where we might want to send an error response. The code to actually send error responses when server_req_respond returns an error is not included and will go in a later PR.

jkarneges avatar May 03 '24 02:05 jkarneges