This HTTP thing works now. Also add a test tool.

This commit is contained in:
Alcaro 2014-12-21 01:21:40 +01:00
parent c37249baf7
commit 8ce7410a0c
2 changed files with 17 additions and 2 deletions

View File

@ -204,22 +204,24 @@ static http_retcode http_query(const char *command, const char *url, const char
if (proxy)
{
sprintf(header,
"%s http://%.128s:%d/%.256s HTTP/1.0\015\012User-Agent: %s\015\012%s\015\012",
"%s http://%.128s:%d/%.256s HTTP/1.0\015\012User-Agent: %s\015\012Host: %s\015\012%s\015\012",
command,
http_server,
http_port,
url,
http_user_agent,
http_server,
additional_header
);
}
else
{
sprintf(header,
"%s /%.256s HTTP/1.0\015\012User-Agent: %s\015\012%s\015\012",
"%s /%.256s HTTP/1.0\015\012User-Agent: %s\015\012Host: %s\015\012%s\015\012",
command,
url,
http_user_agent,
http_server,
additional_header
);
}

13
http_test.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include "http_lib.h"
int main()
{
char url[]="http://unicodesnowmanforyou.com/";
char* urlfilename=NULL;
http_parse_url(url, &urlfilename);
char * out;
http_retcode status=http_get(urlfilename, &out, NULL, NULL);
if (status<0) printf("%i - failure...\n", status);
else printf("%i - success - %s\n", status, out);
}