Skip to content

Commit 93fc9ca

Browse files
committed
split content type header into content type and charset tokens.
1 parent 0dfb0d4 commit 93fc9ca

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/mod_okioki.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ static int mod_okioki_input_handler(request_rec *http_request, apr_hash_t **_arg
169169
char *data;
170170
size_t data_size;
171171
int ret;
172-
const char *content_type;
172+
const char *_content_type;
173+
char *content_type;
174+
char *charset;
175+
char *last_token;
173176

174177
// Create arguments hash table. Then pass these arguments back to the caller.
175178
ASSERT_NOT_NULL(
@@ -194,10 +197,20 @@ static int mod_okioki_input_handler(request_rec *http_request, apr_hash_t **_arg
194197

195198
// Check for the content-type of the request.
196199
ASSERT_NOT_NULL(
197-
content_type = apr_table_get(http_request->headers_in, "Content-type"),
200+
_content_type = apr_table_get(http_request->headers_in, "Content-type"),
198201
HTTP_BAD_REQUEST, "[mod_okioki.c] No content-type for PUT or POST."
199202
)
200203

204+
ASSERT_NOT_NULL(
205+
content_type = apr_pstrdup(pool, _content_type),
206+
HTTP_INTERNAL_SERVER_ERROR, "Could not allocate content-type"
207+
)
208+
209+
// Get the content_type from the content_type string.
210+
content_type = apr_strtok(content_type, ";", &last_token);
211+
// Get the charset from the content_type string.
212+
charset = apr_strtok(NULL, ";", &last_token);
213+
201214
if (strcmp(content_type, "application/x-www-form-urlencoded") == 0) {
202215
ASSERT_HTTP_OK(
203216
ret = mod_okioki_parse_query(http_request, arguments, data, error),

0 commit comments

Comments
 (0)