45 perror(
"HTTPHeader_new");
49 perror(
"HTTPHeader_new name");
53 if (
NULL==(header->
value = strdup(value))) {
54 perror(
"HTTPHeader_new value");
65 assert(header->
value);
79 if (
NULL==(auth=malloc(strlen(
"Basic ")+strlen(login)+1+strlen(pass)+1))) {
80 perror(
"HTTPHeader_basicauth");
90 if (
NULL==(auth=malloc(strlen(
"Basic ")+strlen(auth_encoded)+1))) {
91 perror(
"HTTPHeader_basicauth");
95 strcpy(auth,
"Basic ");
96 strcat(auth, auth_encoded);
108 return header->
value;
114 if (
NULL==(retval=malloc(
sizeof(
struct HTTP_s)))) {
115 perror(
"HTTP_new HTTP_s");
119 if (
NULL==(retval->
body=malloc(1))) {
120 perror(
"HTTP_new body");
127 perror(
"HTTP_new headers");
166 if (
NULL==(newbody=realloc(http->
body,strlen(body)+1))) {
167 perror(
"HTTP_setbody");
171 http->
body = newbody;
172 strcpy(http->
body, body);
198 perror(
"HTTP_addheader");
202 perror(
"HTTP_addheader name malloc");
206 if (
NULL==(headers->
value=malloc(strlen(value)+1))) {
207 perror(
"HTTP_addheader value malloc");
210 strcpy(headers->
value,value);
222 if (
NULL==(retval=malloc(1))) {
223 perror(
"HTTP_getheaders initial malloc");
233 if (
NULL==(newretval=realloc(retval,strlen(retval)+strlen(header->
name)+2+strlen(header->
value)+2+1))) {
234 perror(
"HTTP_getheaders inner loop");
238 strcat(retval,header->
name);
240 strcat(retval,header->
value);
241 strcat(retval,
"\r\n");
255 if (
NULL==(retval=malloc(7+1+(uri?strlen(uri)+1:0)+8+1))) {
256 perror(
"HTTP_getrequest");
263 strcat(retval,
"GET");
275 fprintf(stderr,
"HTTP method not supported\n");
286 strcat(retval,
" HTTP/");
290 strcat(retval,
"1.1");
298 fprintf(stderr,
"HTTP version not supported\n");
302 strcat(retval,
"\r\n");
char * base64_encode(char *plain)
Encode a zero terminated C string in Base64.
Simple Base64 encoding and decoding functions.
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)
void HTTP_addheader(HTTP_t *http, const char *name, const char *value)
char * HTTP_getheaders(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_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.
void sclist_remrecord(sclist_t *sclist, sclistrecord_t *record)
Remove a record in a list.
Basic single chained generic list.
Private list record structure.