如何检测Http请求结束? [英] How to detect end of Http request?

查看:579
本文介绍了如何检测Http请求结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Http请求解析器.我正在以块(字节数组)的形式获取数据并同时对其进行解析.我想知道检测http请求结束的情况.该请求可能包含或可能不包含消息正文.

I am creating a Http request parser. I am getting data in chunks (byte array) and parsing it simultaneously. I want to know the condition of detecting end of http request. The request may or may not contain message body.

谢谢

推荐答案

三种不同的方式:

  • 内容长度标头(标头后的字节数)

  • content-length header (number of bytes following the headers)

分块编码(请求开始时内容长度未知,分块编码将指示何时到达末尾)

chunked encoding (content length unknown at start of request, chunked encoding will indicate when the end is reached)

服务器已关闭连接(http"0.9")

connection closed by server (http "0.9")

这篇关于如何检测Http请求结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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