简体   繁体   English

如何从原始HTTP请求中提取正文?

[英]How to extract body from a raw HTTP request?

In my application, I get a raw HTTP request via TcpListener and TcpClient classes. 在我的应用程序中,我通过TcpListener和TcpClient类获得了原始HTTP请求。 I need to extract the request body. 我需要提取请求正文。 How would you do that? 你会怎么做? I'm thinking about the fastest way. 我正在考虑最快的方法。 I don't need headers, just the body. 我不需要标题,只需要正文。

I can't use HttpListener because of the permissions problem. 由于权限问题,我无法使用HttpListener。

For a raw HTML request, the headers and body will be separated by a blank line. 对于原始HTML请求,标头和正文将由空白行分隔。

Header1: stuff
Header2: More stuff

Body begins here

So it should be as simple as scanning for a blank line. 因此,它应该像扫描空白行一样简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM