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')
|
eol := bytes.IndexByte(payload[start:], '\r')
|
||||||
end := bytes.IndexByte(payload[start:], ' ')
|
end := bytes.IndexByte(payload[start:], ' ')
|
||||||
|
|
||||||
if eol > 0 && eol < end {
|
if eol > 0 {
|
||||||
return payload[start : start + eol]
|
if end == -1 || eol < end {
|
||||||
} else if eol == - 1 { // support for legacy clients with wrong end of lines
|
return payload[start : start + eol]
|
||||||
|
}
|
||||||
|
} else { // support for legacy clients
|
||||||
eol = bytes.IndexByte(payload[start:], '\n')
|
eol = bytes.IndexByte(payload[start:], '\n')
|
||||||
|
|
||||||
if eol > 0 && eol < end {
|
if eol > 0 && (end == - 1 || eol < end) {
|
||||||
return payload[start : start + eol]
|
return payload[start : start + eol]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,18 @@ func TestPath(t *testing.T) {
|
|||||||
if path = Path(payload); !bytes.Equal(path, []byte("/get")) {
|
if path = Path(payload); !bytes.Equal(path, []byte("/get")) {
|
||||||
t.Error("Should find path", string(path))
|
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) {
|
func TestSetPath(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user