Closed nietaki closed 5 years ago
I think the reason I don't call handle_tail
was because that maps more closely to the messages as described here https://tools.ietf.org/html/rfc7540#section-8.1
The tail being the optional headers frame after the body.
Adding this for context rather than a reason not to proceed
This is now explained in the README: https://github.com/nietaki/raxx#requestresponse-flow
(or probably all requests with no body)
I was writing a couple of handlers using
handle_head
,handle_data
andhandle_tail
(as opposed tohandle_request
) where I was only sending the response inhandle_tail
, after doing some processing beforehand. This worked well for POST requests with body, but for GET requestshandle_data
andhandle_tail
wasn't called and the response was never completed. It was still confusing to me after looking at the docs.After some consults I now understand that if the
request
inhandle_head
hasbody
set tofalse
I shouldn't be expecting the other callbacks to be called and I should do all the work inhandle_head
and potentiallyhandle_info
.While I see that this is a perfectly workable approach, I think
handle_tail
should be called in all cases.handle_head
there's no body, I have to do the cleanup here, otherwise I have to wait untilhandle_tail
".handle_tail
is just a way to signal the controller that the request is finished - there isn't even a way to determine it otherwise if the request has body, as far as I know.handle_tail(list, state)
- Called once when a request finishes"So what I'm proposing is always calling
handle_tail
callback for all requests (if handled with the 3 callbacks approach, naturally) and only callinghandle_data
if there is body in the request. Also callinghandle_data
with an empty binary chunk as well probably makes less sense.Anyone opposed?