summaryrefslogtreecommitdiff
path: root/spartan/request.go
diff options
context:
space:
mode:
Diffstat (limited to 'spartan/request.go')
-rw-r--r--spartan/request.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/spartan/request.go b/spartan/request.go
index 36dd225..d6a06f3 100644
--- a/spartan/request.go
+++ b/spartan/request.go
@@ -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
}