Transforms a request handler into a service function.
The serviceFromHandler function adapts a provided handler function to
produce an HTTP service function. It processes incoming HTTP requests and
generates appropriate HTTP responses. Additionally, it enforces protocol
behaviors such as ensuring empty bodies for specific request methods.
Behavior:
When the request method is CONNECT and the response indicates success,
the response body is cleared if it contains any content, ensuring
compliance with HTTP protocol requirements for this method.
For other request methods, the Content-Length header is set if
applicable, based on the size hint of the response body.
For the HEAD method, the response body is always cleared as it is not
expected to contain content.
Transforms a request handler into a service function.
The
serviceFromHandler
function adapts a provided handler function to produce an HTTP service function. It processes incoming HTTP requests and generates appropriate HTTP responses. Additionally, it enforces protocol behaviors such as ensuring empty bodies for specific request methods.Behavior:
CONNECT
and the response indicates success, the response body is cleared if it contains any content, ensuring compliance with HTTP protocol requirements for this method.Content-Length
header is set if applicable, based on the size hint of the response body.HEAD
method, the response body is always cleared as it is not expected to contain content.