[erlang-bugs] Packet type http and httph in {inet,ssl}:setopts/2

Sverker Eriksson <>
Fri Jul 3 17:06:16 CEST 2009

Oscar Hellström wrote:
> Hi All,
> In the documentation in the inet module the last line reads:
> "Note that the packet type httph is not needed when reading from a socket."
> This isn't quite true if you want to read HTTP Trailers which can be
> found after an entity body using the chunked transfer coding. Setting
> the option {packet, http} and then reading the following data:
> "Trailer-1: 1\r\n\r\n"
> Will return {http_error, "Trailer-1: 1\r\n"} instead of {ok,
> {http_header, ...}}. I guess that's because the http parser is keeping a
> state of some sort.
Yes, the socket holds a state and automatically switches from http to 
httph after a request or response has been received.
When the parser is called via erlang:decode_packet/3, no such state exist.

> Using the option {packet, httph} however works well
> for reading trailer both for the ssl module and gen_tcp / inet. Is there
> any possibility to document the use of packet type httph as a valid
> option for {inet,ssl}:setopts/2 as well?
Yes, I will make that more clear. I guess "httph is not needed" was to 
over-simplify things.

/Sverker, Erlang/OTP

More information about the erlang-bugs mailing list