diff options
author | Valentin Bartenev <vbart@nginx.com> | 2018-07-05 16:43:45 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2018-07-05 16:43:45 +0300 |
commit | 7e3de003c7e6078be822b64c40042cb4385210fd (patch) | |
tree | af9fcbc3d4ca640ddc10b81b8f6ac987eaac691c /src/nxt_router.c | |
parent | 234deb51f48b43a5fb080d16746838f355b725b4 (diff) | |
download | unit-7e3de003c7e6078be822b64c40042cb4385210fd.tar.gz unit-7e3de003c7e6078be822b64c40042cb4385210fd.tar.bz2 |
PHP: fixed request body processing.
The implementation of module was based on the assumption that PHP reads request
body and headers in the particular order. For the POST request the body goes
before headers and vice versa for all other requests.
But as it appeared later, this order is unspecified and depends on many factors,
including the particular code of PHP application. Among other factors those
can affect ordering:
- presence of "Content-Type" header;
- "variables_order" php.ini setting;
- "enable_post_data_reading" php.ini setting;
- reading php://input by application;
and this list can be incomplete.
As a temporary workaround, request body now is always put before headers and it
is gracefully skipped whenever PHP wants to get headers.
This closes #144 issue on GitHub.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_router.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c index 162e7073..1b4c1596 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -4375,7 +4375,6 @@ nxt_php_prepare_msg(nxt_task_t *task, nxt_app_request_t *r, { nxt_int_t rc; nxt_buf_t *b; - nxt_bool_t method_is_post; nxt_http_field_t *field; nxt_app_request_header_t *h; @@ -4432,17 +4431,9 @@ nxt_php_prepare_msg(nxt_task_t *task, nxt_app_request_t *r, RC(nxt_app_msg_write_size(task, wmsg, h->parsed_content_length)); RC(nxt_app_msg_write_size(task, wmsg, r->body.preread_size)); - method_is_post = h->method.length == 4 - && h->method.start[0] == 'P' - && h->method.start[1] == 'O' - && h->method.start[2] == 'S' - && h->method.start[3] == 'T'; - - if (method_is_post) { - for (b = r->body.buf; b != NULL; b = b->next) { - RC(nxt_app_msg_write_raw(task, wmsg, b->mem.pos, - nxt_buf_mem_used_size(&b->mem))); - } + for (b = r->body.buf; b != NULL; b = b->next) { + RC(nxt_app_msg_write_raw(task, wmsg, b->mem.pos, + nxt_buf_mem_used_size(&b->mem))); } nxt_list_each(field, h->fields) { @@ -4455,13 +4446,6 @@ nxt_php_prepare_msg(nxt_task_t *task, nxt_app_request_t *r, /* end-of-headers mark */ NXT_WRITE(&eof); - if (!method_is_post) { - for (b = r->body.buf; b != NULL; b = b->next) { - RC(nxt_app_msg_write_raw(task, wmsg, b->mem.pos, - nxt_buf_mem_used_size(&b->mem))); - } - } - #undef NXT_WRITE #undef RC |