update http packet parsing method

This commit is contained in:
xvzc 2022-03-05 08:49:28 +09:00
parent b7a76ab5ec
commit 45a990d296

View File

@ -90,7 +90,7 @@ func (p *HttpPacket) IsConnectMethod() bool {
func (p *HttpPacket) Tidy() {
s := string(p.raw)
lines := strings.Split(s, "\n")
lines := strings.Split(s, "\r\n")
lines[0] = p.method + " " + p.path + " " + p.version
@ -101,14 +101,17 @@ func (p *HttpPacket) Tidy() {
}
result := ""
for i := 0; i < len(lines); i++ {
if lines[i] == "" {
continue
}
result += lines[i] + "\n"
result += lines[i] + "\r\n"
}
result += "\r\n"
p.raw = []byte(result)
}