HTTP Chunked编码。需要一个SPEC中提到的“预告片”的例子 [英] HTTP Chunked Encoding. Need an example of 'Trailer' mentioned in SPEC

查看:140
本文介绍了HTTP Chunked编码。需要一个SPEC中提到的“预告片”的例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为透明代理编写HTTP解析器。让我感到困惑的是预告片 Transfer-Encoding:chunked 的规格中提到。它看起来像什么?

I am writing an HTTP parser for a transparent proxy. What is stumping me is the Trailer: mentioned in the specs for Transfer-Encoding: chunked. What does it look like?

通常情况下,HTTP分块就像这样结束。

Normally, a HTTP chunked ends like this.

0\r\n
\r\n

我感到困惑的是,如果有某种尾随标题,如何检测块的结尾...

What I am confused about is how to detect the end of the chunk if there is some sort of trailing headers...

更新:我相信一个简单的 \\\\\ n 空行足以检测尾随标题的结尾。 ..这是正确的吗?

UPDATE: I believe that a simple \r\n\r\n i.e. an empty line is enough to detect the end of trailing headers... Is that correct?

推荐答案


0 \\ nn

SomeAfterHeader:数据 \\\\ n

\\\\ n

换句话说,只需查找 \\\\\\\ n ,用外行的话来说:一个空行。检测分块传输的结束。但是在执行此操作之前读取每个块非常重要。因为分块数据本身可以包含空行,这些空行会被错误地检测为流的末尾。

In other words, it is sufficient to look for a \r\n\r\n, in layman's terms: a blank line. To detect the end of a chunked transmission. But it is very important that each chunk is read before doing this. Because the chunked data itself can contain blank lines which would erroneously be detected as the end of the stream.

这篇关于HTTP Chunked编码。需要一个SPEC中提到的“预告片”的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆