Reprinted: http://erlang.2086793.n4.nabble.com/Packet-type-http-and-httph-in-inet-ssl-setopts-2-td2121721.html Hi all, In the documentation in the inet module the last line reads: "Note thatPacketTypeHttphIs 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. 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 {Inet, SSL}: setopts/2 as well? Best regards -- Oscar hellström,[Hidden email] Office: + 44 20 7655 0337 Mobile: + 44 798 45 44 773 Erlang training and Consulting Ltd Http://www.erlang-consulting.com/ ________________________________________________________________ Erlang-bugs mailing list. SeeHttp://www.erlang.org/faq.html Erlang-bugs (AT) erlang.org |
Sverker Eriksson Jul 03,200 9;
117 posts |
Oscar hellström wrote: > Hi all, > > In the documentation in the inet module the last line reads: > "Note thatPacketTypeHttphIs 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 > State of some sort. « [Hide part of quote] Yes, the socket holds a state and automatically switches from http HttphAfter a request or response has been already ed. 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 usePacketTypeHttphAs a valid > Option for {Inet, SSL}: setopts/2 as well? > > Yes, I will make that more clear. I guess"HttphIs not needed "was Over-simplify things. /Sverker, Erlang/OTP ________________________________________________________________ Erlang-bugs mailing list. SeeHttp://www.erlang.org/faq.html Erlang-bugs (AT) erlang.org |