Packet Type HTTP and httph in {Inet, SSL}: setopts/2

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.