Skip to content

kocotian/http.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

http.h

simple and small http library for C99, just include header in your project and you ready to GET.

for example, GET / from suckless.org on port 80:

#include "http.h"

int
main(void)
{
	char *response; long long int size;
	if(!(size = httpGET("suckless.org", 80, "/", &response))) return -1;
	printf("%s", response);
	/* or if you don't want http header: printf("%s", truncateHeader(response)); */
	free(response);
	return 0;
}

warning:

parseResponseLine() and getResponseStatus() may be broken, i'll repair them

compatibility:

any POSIX 7 compliant system: yes

windows: no

additional features:

if you want to change maximal request length (default 1024), #define MAX_REQUEST_LEN as new request length before #including "http.h"