45 perror(
"HTTPHeader_new");
48 header->
value = strdup(value);
56 assert(header->
value);
71 if (
NULL==(auth=malloc(strlen(
"Basic ")+strlen(login)+1+strlen(pass)+1))) {
72 perror(
"HTTPHeader_basicauth");
83 if (
NULL==(auth=malloc(strlen(
"Basic ")+strlen(auth_encoded)+1))) {
84 perror(
"HTTPHeader_basicauth");
88 strcpy(auth,
"Basic ");
89 strcat(auth, auth_encoded);
100 return header->
value;
106 if (
NULL==(retval=malloc(
sizeof(
struct HTTP_s)))) {
107 perror(
"HTTP_new HTTP_s");
111 if (
NULL==(retval->
body=malloc(1))) {
112 perror(
"HTTP_new body");
119 perror(
"HTTP_new headers");
171 perror(
"HTTP_addheader");
175 perror(
"HTTP_addheader name malloc");
179 if (
NULL==(headers->
value=malloc(strlen(value)+1))) {
180 perror(
"HTTP_addheader value malloc");
183 strcpy(headers->
value,value);
195 if (
NULL==(retval=malloc(1))) {
196 perror(
"HTTP_getheaders initial malloc");
206 if (
NULL==(newretval=realloc(retval,strlen(retval)+strlen(header->
name)+2+strlen(header->
value)+2+1))) {
207 perror(
"HTTP_getheaders inner loop");
211 strcat(retval,header->
name);
213 strcat(retval,header->
value);
214 strcat(retval,
"\r\n");
227 if (
NULL==(retval=malloc(7+1+strlen(uri)+1+8+1))) {
228 perror(
"HTTP_getrequest");
235 strcat(retval,
"GET");
247 fprintf(stderr,
"HTTP method not supported\n");
257 strcat(retval,
" HTTP/");
261 strcat(retval,
"1.1");
269 fprintf(stderr,
"HTTP version not supported\n");
273 strcat(retval,
"\r\n");
283 if (
NULL==(newbody=realloc(http->
body,strlen(body)+1))) {
284 perror(
"HTTP_setbody");
288 http->
body = newbody;
289 strcpy(http->
body, body);
char * base64_encode(char *plain)
Encode a zero terminated C string in Base64.
Simple Base64 encoding and decoding functions.
char * HTTPHeader_getvalue(HTTPHeader_t *header)
void HTTPHeader_del(HTTPHeader_t *header)
void HTTP_del(HTTP_t *http)
void HTTP_addheader(HTTP_t *http, const char *name, const char *value)
struct HTTPHeaders_s HTTPHeaders_t
char * HTTP_getheaders(const HTTP_t *http)
HTTPHeader_t * HTTPHeader_basicauth(const char *login, const char *pass)
struct HTTPHeader_s HTTPHeader_t
void HTTP_setbody(HTTP_t *http, const char *body)
char * HTTP_getbody(HTTP_t *http)
HTTPHeader_t * HTTPHeader_new(const char *name, const char *value)
char * HTTPHeader_getname(HTTPHeader_t *header)
char * HTTP_getrequest(const HTTPMethod_t method, const char *uri, const HTTPVersion_t version)
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.
Basic single chained generic list.
Private list record structure.