diff options
| author | 2022-09-25 07:42:57 +0200 | |
|---|---|---|
| committer | 2022-09-25 07:42:57 +0200 | |
| commit | b070d2d8f88866bf83103c34c4d86352c6b74e8d (patch) | |
| tree | f3d48f9a370b92560e25cc0d96dac252ee851b96 /httpd.c | |
| parent | New function srv_archive(). (diff) | |
| download | snac2-b070d2d8f88866bf83103c34c4d86352c6b74e8d.tar.gz snac2-b070d2d8f88866bf83103c34c4d86352c6b74e8d.tar.xz snac2-b070d2d8f88866bf83103c34c4d86352c6b74e8d.zip | |
The HTTP request headers are stored in a plain dict.
Diffstat (limited to 'httpd.c')
| -rw-r--r-- | httpd.c | 10 |
1 files changed, 3 insertions, 7 deletions
| @@ -24,8 +24,7 @@ int server_get_handler(d_char *req, char *q_path, | |||
| 24 | /* basic server services */ | 24 | /* basic server services */ |
| 25 | { | 25 | { |
| 26 | int status = 0; | 26 | int status = 0; |
| 27 | char *req_hdrs = xs_dict_get(req, "headers"); | 27 | char *acpt = xs_dict_get(req, "accept"); |
| 28 | char *acpt = xs_dict_get(req_hdrs, "accept"); | ||
| 29 | 28 | ||
| 30 | if (acpt == NULL) | 29 | if (acpt == NULL) |
| 31 | return 400; | 30 | return 400; |
| @@ -90,7 +89,6 @@ void httpd_connection(int rs) | |||
| 90 | { | 89 | { |
| 91 | FILE *f; | 90 | FILE *f; |
| 92 | xs *req; | 91 | xs *req; |
| 93 | char *req_hdrs; | ||
| 94 | char *method; | 92 | char *method; |
| 95 | int status = 0; | 93 | int status = 0; |
| 96 | char *body = NULL; | 94 | char *body = NULL; |
| @@ -106,10 +104,8 @@ void httpd_connection(int rs) | |||
| 106 | 104 | ||
| 107 | req = xs_httpd_request(f, &payload, &p_size); | 105 | req = xs_httpd_request(f, &payload, &p_size); |
| 108 | 106 | ||
| 109 | req_hdrs = xs_dict_get(req, "headers"); | 107 | method = xs_dict_get(req, "method"); |
| 110 | 108 | q_path = xs_dup(xs_dict_get(req, "path")); | |
| 111 | method = xs_dict_get(req_hdrs, "method"); | ||
| 112 | q_path = xs_dup(xs_dict_get(req_hdrs, "path")); | ||
| 113 | 109 | ||
| 114 | /* crop the q_path from leading / and the prefix */ | 110 | /* crop the q_path from leading / and the prefix */ |
| 115 | if (xs_endswith(q_path, "/")) | 111 | if (xs_endswith(q_path, "/")) |