summaryrefslogtreecommitdiff
path: root/spartan
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-10-30 17:24:22 -0600
committertjpcc <tjp@ctrl-c.club>2023-10-30 17:24:22 -0600
commit4c817bf712e4ffed34fdd78375fcd7157cd14dc3 (patch)
treed454598a1d10b5818031af6daf9a1c83049b9fa7 /spartan
parent634b82d24335564139b43617d641d6880219e321 (diff)
allow for bare LF line endings in spartanv1.5.0
Diffstat (limited to 'spartan')
-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
}