diff options
Diffstat (limited to 'xs_httpd.h')
| -rw-r--r-- | xs_httpd.h | 21 |
1 files changed, 10 insertions, 11 deletions
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | d_char *xs_url_dec(char *str); | 7 | d_char *xs_url_dec(char *str); |
| 8 | d_char *xs_url_vars(char *str); | 8 | d_char *xs_url_vars(char *str); |
| 9 | d_char *xs_httpd_request(FILE *f); | 9 | d_char *xs_httpd_request(FILE *f, d_char **payload, int *p_size); |
| 10 | void xs_httpd_response(FILE *f, int status, d_char *headers, char *body, int b_size); | 10 | void xs_httpd_response(FILE *f, int status, d_char *headers, char *body, int b_size); |
| 11 | 11 | ||
| 12 | 12 | ||
| @@ -69,7 +69,7 @@ d_char *xs_url_vars(char *str) | |||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | 71 | ||
| 72 | d_char *xs_httpd_request(FILE *f) | 72 | d_char *xs_httpd_request(FILE *f, d_char **payload, int *p_size) |
| 73 | /* processes an httpd connection */ | 73 | /* processes an httpd connection */ |
| 74 | { | 74 | { |
| 75 | xs *headers = NULL; | 75 | xs *headers = NULL; |
| @@ -127,19 +127,18 @@ d_char *xs_httpd_request(FILE *f) | |||
| 127 | 127 | ||
| 128 | xs_socket_timeout(fileno(f), 5.0, 0.0); | 128 | xs_socket_timeout(fileno(f), 5.0, 0.0); |
| 129 | 129 | ||
| 130 | if ((v = xs_dict_get(headers, "content-length")) != NULL) { | ||
| 131 | /* if it has a payload, load it */ | ||
| 132 | *p_size = atoi(v); | ||
| 133 | *payload = xs_read(f, *p_size); | ||
| 134 | } | ||
| 135 | |||
| 130 | /* does it have a payload with form urlencoded variables? */ | 136 | /* does it have a payload with form urlencoded variables? */ |
| 131 | v = xs_dict_get(headers, "content-type"); | 137 | v = xs_dict_get(headers, "content-type"); |
| 132 | 138 | ||
| 133 | if (v && strcmp(v, "application/x-www-form-urlencoded") == 0) { | 139 | if (v && strcmp(v, "application/x-www-form-urlencoded") == 0) { |
| 134 | if ((v = xs_dict_get(headers, "content-length")) != NULL) { | 140 | xs *upl = xs_url_dec(*payload); |
| 135 | int cl = atoi(v); | 141 | p_vars = xs_url_vars(upl); |
| 136 | xs *payload; | ||
| 137 | |||
| 138 | if ((payload = xs_read(f, cl)) != NULL) { | ||
| 139 | xs *upl = xs_url_dec(payload); | ||
| 140 | p_vars = xs_url_vars(upl); | ||
| 141 | } | ||
| 142 | } | ||
| 143 | } | 142 | } |
| 144 | else | 143 | else |
| 145 | p_vars = xs_dict_new(); | 144 | p_vars = xs_dict_new(); |