summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Porzelt <tp@cryosphere.de>2009-10-04 17:45:27 +0200
committerThomas Porzelt <tp@cryosphere.de>2009-10-04 17:45:27 +0200
commit5c686391cb20f8bd709de0a3737aef81766080bf (patch)
treeeb69746704fed9ca9834faaae4cc37d902ac8fd1
parentbdfdd127c10729d8d2ad1321344ac25c97162f53 (diff)
downloadweighttp-5c686391cb20f8bd709de0a3737aef81766080bf.tar.gz
weighttp-5c686391cb20f8bd709de0a3737aef81766080bf.zip
add User-Agent header to request
-rw-r--r--src/weighttp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/weighttp.c b/src/weighttp.c
index 7481485..fbbe3ad 100644
--- a/src/weighttp.c
+++ b/src/weighttp.c
@@ -126,7 +126,7 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
if (*url == '\0')
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 ");
strcat(req, url);
@@ -134,10 +134,13 @@ static char *forge_request(char *url, char keep_alive, char **host, uint16_t *po
strcat(req, *host);
if (*port != 80)
sprintf(req + strlen(req), ":%"PRIu16, *port);
+
+ sprintf(req + strlen(req), "\r\nUser-Agent: weighttp/" VERSION "\r\n");
+
if (keep_alive)
- strcat(req, "\r\nConnection: keep-alive\r\n\r\n");
+ strcat(req, "Connection: keep-alive\r\n\r\n");
else
- strcat(req, "\r\nConnection: close\r\n\r\n");
+ strcat(req, "Connection: close\r\n\r\n");
return req;
}