40 if (
NULL==(retval=malloc(
sizeof(
struct HTTP_s)))) {
47 if (
NULL==(retval->
body=malloc(1))) {
48 perror(
"HTTP_new empty body allocation");
64 perror(
"HTTP_addheader");
68 perror(
"HTTP_addheader name malloc");
72 if (
NULL==(headers->
value=malloc(strlen(value)+1))) {
73 perror(
"HTTP_addheader value malloc");
76 strcpy(headers->
value,value);
88 if (
NULL==(retval=malloc(1))) {
89 perror(
"HTTP_getheaders initial malloc");
99 if (
NULL==(newretval=realloc(retval,strlen(retval)+strlen(header->
name)+2+strlen(header->
value)+2+1))) {
100 perror(
"HTTP_getheaders inner loop");
104 strcat(retval,header->
name);
106 strcat(retval,header->
value);
107 strcat(retval,
"\r\n");
141 if (
NULL==(retval=malloc(7+1+strlen(uri)+1+8+1))) {
142 perror(
"HTTP_getrequest");
149 strcat(retval,
"GET");
161 fprintf(stderr,
"HTTP method not supported\n");
171 strcat(retval,
" HTTP/");
175 strcat(retval,
"1.1");
183 fprintf(stderr,
"HTTP version not supported\n");
187 strcat(retval,
"\r\n");
197 if (
NULL==(newbody=realloc(http->
body,strlen(body)+1))) {
198 perror(
"HTTP_setbody");
202 http->
body = newbody;
203 strcpy(http->
body, body);
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)
void HTTP_setbody(HTTP_t *http, const char *body)
char * HTTP_getbody(HTTP_t *http)
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.