Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

解析Http协议有问题 #15

Open
ruijiexie opened this issue Jun 20, 2018 · 3 comments
Open

解析Http协议有问题 #15

ruijiexie opened this issue Jun 20, 2018 · 3 comments

Comments

@ruijiexie
Copy link

ruijiexie commented Jun 20, 2018

HttpRequest.cs里
private string GetRequestData(Stream stream)
{
var length = 0;
var data = string.Empty;

        do
        {
            length = stream.Read(bytes, 0, MAX_SIZE - 1);
            data += Encoding.UTF8.GetString(bytes, 0, length);
        } while (length > 0 && !data.Contains("\r\n\r\n"));

        return data;
    }

这个解析HTTP协议自己想想的,HTTP头和BODY不同时发送都处理不了。。

@qinyuanpei
Copy link
Owner

HTTP头和Body难道不是一次性发过去的吗?为什么你会觉得这里处理不了呢?你的方案又是什么呢?

@ruijiexie
Copy link
Author

Tcp处理HTTP协议要处理的太多,用HttpListener方便很多

@qinyuanpei
Copy link
Owner

那就是失去意义了,我本来就是要从无到有地做一个Http Server啊,这种方式我很早就尝试过了,用它做静态服务器会比较好些,而我这个显然想尝试更多的内容

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants