allow for bare LF line endings in spartan
This commit is contained in:
parent
634b82d243
commit
4c817bf712
|
@ -32,21 +32,19 @@ func ParseRequest(rdr io.Reader) (*types.Request, int, error) {
|
|||
if err != io.EOF && err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
line = strings.TrimSuffix(line, "\n")
|
||||
line = strings.TrimSuffix(line, "\r")
|
||||
|
||||
host, rest, ok := strings.Cut(line, " ")
|
||||
if !ok {
|
||||
return nil, 0, InvalidRequestLine
|
||||
}
|
||||
path, rest, ok := strings.Cut(rest, " ")
|
||||
if !ok {
|
||||
if !ok || len(rest) == 0 {
|
||||
return nil, 0, InvalidRequestLine
|
||||
}
|
||||
|
||||
if len(rest) < 2 || line[len(line)-2:] != "\r\n" {
|
||||
return nil, 0, InvalidRequestLineEnding
|
||||
}
|
||||
|
||||
contentlen, err := strconv.Atoi(rest[:len(rest)-2])
|
||||
contentlen, err := strconv.Atoi(rest)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue