Packet type http and httph in {inet,ssl}:setopts/2

來源:互聯網
上載者:User
轉載:http://erlang.2086793.n4.nabble.com/Packet-type-http-and-httph-in-inet-ssl-setopts-2-td2121721.htmlHi 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. 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?

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. See http://www.erlang.org/faq.html
erlang-bugs (at) erlang.org

Sverker Eriksson Jul 03, 2009; 11:06pm

 

117 posts 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. « [hide part of quote]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

________________________________________________________________
erlang-bugs mailing list. See http://www.erlang.org/faq.html
erlang-bugs (at) erlang.org

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.