add User-Agent header to request
This commit is contained in:
parent
bdfdd127c1
commit
5c686391cb
@ -126,7 +126,7 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
|
|||||||
if (*url == '\0')
|
if (*url == '\0')
|
||||||
url = "/";
|
url = "/";
|
||||||
|
|
||||||
req = W_MALLOC(char, sizeof("GET HTTP/1.1\r\nHost: :65536\r\nConnection: keep-alive\r\n\r\n") + strlen(*host) + strlen(url));
|
req = W_MALLOC(char, sizeof("GET HTTP/1.1\r\nHost: :65536\r\nUser-Agent: weighttp/\r\nConnection: keep-alive\r\n\r\n") + strlen(VERSION) + strlen(*host) + strlen(url));
|
||||||
|
|
||||||
strcpy(req, "GET ");
|
strcpy(req, "GET ");
|
||||||
strcat(req, url);
|
strcat(req, url);
|
||||||
@ -134,10 +134,13 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
|
|||||||
strcat(req, *host);
|
strcat(req, *host);
|
||||||
if (*port != 80)
|
if (*port != 80)
|
||||||
sprintf(req + strlen(req), ":%"PRIu16, *port);
|
sprintf(req + strlen(req), ":%"PRIu16, *port);
|
||||||
|
|
||||||
|
sprintf(req + strlen(req), "\r\nUser-Agent: weighttp/" VERSION "\r\n");
|
||||||
|
|
||||||
if (keep_alive)
|
if (keep_alive)
|
||||||
strcat(req, "\r\nConnection: keep-alive\r\n\r\n");
|
strcat(req, "Connection: keep-alive\r\n\r\n");
|
||||||
else
|
else
|
||||||
strcat(req, "\r\nConnection: close\r\n\r\n");
|
strcat(req, "Connection: close\r\n\r\n");
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user