Configuration.decodeHTTPResponse()
Description
Appends a decodeHTTPResponse filter to the current pipeline layout.
A decodeHTTPResponse filter decodes HTTP/1 response messages from a raw byte stream.
- INPUT - Data stream to decode HTTP/1 response messages from.
- OUTPUT - HTTP/1 response Messages decoded from the input Data stream.
After decoding, the output Message has:
- head
- protocol - Can be "HTTP/1.0" or "HTTP/1.1"
- status - Response status code
- statusText - Response reason phrase
- headers - Header fields
- body - Message body
Header names are all converted to lowercase. So "Connection" becomes "connection" and "Content-Type" becomes "content-type".
This filter only supports HTTP/1.x. For compatibility with HTTP/2, check out muxHTTP().
Response to HEAD requests
When decoding a response to a HEAD request, you need to tell the filter that the response is supposed to have no body following the header so that the decoder won't be waiting for a body perpetually. You do so by the bodiless option in the options parameter. It can be a boolean value or a function that returns a boolean value.
Handling trasport errors
StreamEnd events on the input, when coming with an error, will be decoded as a 4xx/5xx responses, depending on the error code carried by the event.
StreamEnd Error | Status Code + Reason Phrase | |
---|---|---|
CannotResolve | 502 Cannot Resolve | |
ConnectionRefused | 502 Connection Refused | |
Unauthorized | 401 Unauthorized | |
ReadError | 502 Read Error | |
WriteError | 502 Write Error | |
ConnectionTimeout | 504 Gateway Timeout | |
ReadTimeout | 504 Gateway Timeout | |
WriteTimeout | 504 Gateway Timeout | |
Other errors... | 502 Bad Gateway |
Syntax
pipy().pipeline().decodeHTTPResponse()pipy().pipeline().decodeHTTPResponse({bodiless,})
Parameters
decodeHTTPResponse(handler?)
No description
The same Configuration object.