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

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. 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
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.
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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值