46 perror(
"HTTPHeader_new");
50 perror(
"HTTPHeader_new name");
54 if (
NULL==(header->
value = strdup(value))) {
55 perror(
"HTTPHeader_new value");
67 assert(header->
value);
81 if (
NULL==(auth=malloc(strlen(
"Basic ")+strlen(login)+1+strlen(pass)+1))) {
82 perror(
"HTTPHeader_basicauth");
92 if (
NULL==(auth=malloc(strlen(
"Basic ")+strlen(auth_encoded)+1))) {
93 perror(
"HTTPHeader_basicauth");
97 strcpy(auth,
"Basic ");
98 strcat(auth, auth_encoded);
110 return header->
value;
116 if (
NULL==(retval=malloc(
sizeof(
struct HTTP_s)))) {
117 perror(
"HTTP_new HTTP_s");
121 if (
NULL==(retval->
body=malloc(1))) {
122 perror(
"HTTP_new body");
129 perror(
"HTTP_new headers");
168 if (
NULL==(newbody=realloc(http->
body,strlen(body)+1))) {
169 perror(
"HTTP_setbody");
173 http->
body = newbody;
174 strcpy(http->
body, body);
193 perror(
"HTTP_addheader, header already in a list");
198 perror(
"HTTP_addheader");
242 if (0==strcmp(header_name,
name)) {
246 assert(header_value);
247 if (0==strcmp(header_value,value))
268 perror(
"HTTP_addheader");
284 if (
NULL==(retval=malloc(7+1+(uri?strlen(uri)+1:0)+8+1))) {
285 perror(
"HTTP_getrequest");
292 strcat(retval,
"GET");
304 fprintf(stderr,
"HTTP method not supported\n");
315 strcat(retval,
" HTTP/");
319 strcat(retval,
"1.1");
327 fprintf(stderr,
"HTTP version not supported\n");
331 strcat(retval,
"\r\n");
335static char* strconcat(
char* dst,
char* src) {
341 if (
NULL==(newdst=realloc(dst,strlen(dst)+strlen(src)+1))) {
359 if (
NULL==(headers=strdup(
""))) {
360 perror(
"HTTP_buildheaders headers");
368 headers=strconcat(headers,
": ");
370 headers=strconcat(headers,
"\r\n");
char * base64_encode(char *plain)
Encode a zero terminated C string in Base64.
Simple Base64 encoding and decoding functions.
HTTPHeader_t * HTTP_firstheader(const HTTP_t *http)
char * HTTP_setbody(HTTP_t *http, const char *body)
char * HTTPHeader_getvalue(HTTPHeader_t *header)
void HTTPHeader_del(HTTPHeader_t *header)
void HTTP_del(HTTP_t *http)
HTTP_t * HTTP_addheader(HTTP_t *http, HTTPHeader_t *header)
char * HTTP_buildheaders(const HTTP_t *http)
HTTPHeader_t * HTTPHeader_basicauth(const char *login, const char *pass)
struct HTTPHeader_s HTTPHeader_t
char * HTTP_getbody(HTTP_t *http)
HTTPHeader_t * HTTPHeader_new(const char *name, const char *value)
char * HTTPHeader_getname(HTTPHeader_t *header)
char * HTTP_buildrequest(const HTTPMethod_t method, const char *uri, const HTTPVersion_t version)
HTTP_t * HTTP_delheader(HTTP_t *http, HTTPHeader_t *header)
HTTPHeader_t * HTTP_nextheader(const HTTPHeader_t *header)
HTTPHeader_t * HTTP_findheader(const HTTPHeader_t *start, const char *name, const char *value)
HTTP parsing and building library.
enum HTTPVersion_e HTTPVersion_t
enum HTTPMethod_e HTTPMethod_t
void * sclist_getvalue(sclistrecord_t *record)
Returns the value pointer stored in the record.
sclist_t * sclist_new()
Allocate and initialize the internal list structure.
sclistrecord_t * sclist_nextrecord(const sclistrecord_t *record)
Returns the pointer on the record following the specified one.
sclistrecord_t * sclist_addrecord(sclist_t *sclist, void *value)
Add a value at the end of the list.
sclistrecord_t * sclist_firstrecord(const sclist_t *sclist)
Returns the pointer on the first list record.
void sclist_remrecord(sclist_t *sclist, sclistrecord_t *record)
Remove a record in a list.
Basic single chained generic list.
Private list record structure.