mirror of
https://github.com/wg/wrk
synced 2025-02-19 10:02:53 +08:00
allow Host header to be overridden with -H
This commit is contained in:
parent
43d3193914
commit
ae7a043678
20
src/wrk.c
20
src/wrk.c
@ -383,17 +383,23 @@ static char *extract_url_part(char *url, struct http_parser_url *parser_url, enu
|
|||||||
|
|
||||||
static char *format_request(char *host, char *port, char *path, char **headers) {
|
static char *format_request(char *host, char *port, char *path, char **headers) {
|
||||||
char *req = NULL;
|
char *req = NULL;
|
||||||
|
char *head = NULL;
|
||||||
aprintf(&req, "GET %s HTTP/1.1\r\n", path);
|
|
||||||
aprintf(&req, "Host: %s", host);
|
|
||||||
if (port) aprintf(&req, ":%s", port);
|
|
||||||
aprintf(&req, "\r\n");
|
|
||||||
|
|
||||||
for (char **h = headers; *h != NULL; h++) {
|
for (char **h = headers; *h != NULL; h++) {
|
||||||
aprintf(&req, "%s\r\n", *h);
|
aprintf(&head, "%s\r\n", *h);
|
||||||
|
if (!strncasecmp(*h, "Host:", 5)) {
|
||||||
|
host = NULL;
|
||||||
|
port = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aprintf(&req, "\r\n");
|
aprintf(&req, "GET %s HTTP/1.1\r\n", path);
|
||||||
|
if (host) aprintf(&req, "Host: %s", host);
|
||||||
|
if (port) aprintf(&req, ":%s", port);
|
||||||
|
if (host) aprintf(&req, "\r\n");
|
||||||
|
aprintf(&req, "%s\r\n", head ? head : "");
|
||||||
|
|
||||||
|
free(head);
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user