mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
+6
-4
@@ -346,12 +346,14 @@ func Path(payload []byte) []byte {
|
||||
eol := bytes.IndexByte(payload[start:], '\r')
|
||||
end := bytes.IndexByte(payload[start:], ' ')
|
||||
|
||||
if eol > 0 && eol < end {
|
||||
return payload[start : start + eol]
|
||||
} else if eol == - 1 { // support for legacy clients with wrong end of lines
|
||||
if eol > 0 {
|
||||
if end == -1 || eol < end {
|
||||
return payload[start : start + eol]
|
||||
}
|
||||
} else { // support for legacy clients
|
||||
eol = bytes.IndexByte(payload[start:], '\n')
|
||||
|
||||
if eol > 0 && eol < end {
|
||||
if eol > 0 && (end == - 1 || eol < end) {
|
||||
return payload[start : start + eol]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +243,18 @@ func TestPath(t *testing.T) {
|
||||
if path = Path(payload); !bytes.Equal(path, []byte("/get")) {
|
||||
t.Error("Should find path", string(path))
|
||||
}
|
||||
|
||||
payload = []byte("GET /get\n")
|
||||
|
||||
if path = Path(payload); !bytes.Equal(path, []byte("/get")) {
|
||||
t.Error("Should find path", string(path))
|
||||
}
|
||||
|
||||
payload = []byte("GET /get")
|
||||
|
||||
if path = Path(payload); !bytes.Equal(path, []byte("/get")) {
|
||||
t.Error("Should find path", string(path))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetPath(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user