mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Fix httpHeader when header value contain ":"
This commit is contained in:
@@ -255,14 +255,17 @@ function httpHeader(payload, name) {
|
||||
}
|
||||
|
||||
header.start = -1
|
||||
header.valueStart = -1
|
||||
continue;
|
||||
} else if (c == 10) { // "\r"
|
||||
i++
|
||||
continue;
|
||||
} else if (c == 58) { // ":" Header/value separator symbol
|
||||
header.valueStart = i + 1;
|
||||
i++
|
||||
continue;
|
||||
if (header.valueStart == -1) {
|
||||
header.valueStart = i + 1;
|
||||
i++
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (header.start == -1) header.start = i;
|
||||
@@ -511,9 +514,9 @@ function TEST_httpBodyParam() {
|
||||
}
|
||||
|
||||
function TEST_httpHeader() {
|
||||
const examplePayload = "GET / HTTP/1.1\r\nUser-Agent: Node\r\nContent-Length:5\r\n\r\nhello";
|
||||
const examplePayload = "GET / HTTP/1.1\r\nHost: localhost:3000\r\nUser-Agent: Node\r\nContent-Length:5\r\n\r\nhello";
|
||||
|
||||
let expected = {"User-Agent": "Node", "Content-Length": "5"}
|
||||
let expected = {"Host": "localhost:3000", "User-Agent": "Node", "Content-Length": "5"}
|
||||
|
||||
Object.keys(expected).forEach(function(name){
|
||||
let payload = Buffer.from(examplePayload);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "goreplay_middleware",
|
||||
"version": "0.1.11",
|
||||
"version": "0.1.12",
|
||||
"description": "Package for writing middleware for GoReplay https://goreplay.org",
|
||||
"main": "middleware.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user