Permalink
Browse files

now we allow PUT chunked requests.

  • Loading branch information...
1 parent 4efc499 commit c8547b827630fe5dcae071b222d79fd77ab486d5 @agentzh committed Aug 2, 2010
Showing with 26 additions and 6 deletions.
  1. +18 −2 src/ngx_http_chunkin_filter_module.c
  2. +1 −0 test/t/error.t
  3. +2 −0 test/t/random.t
  4. +5 −4 test/t/sanity.t
@@ -132,6 +132,8 @@ ngx_http_chunkin_merge_conf(ngx_conf_t *cf, void *parent, void *child)
static ngx_flag_t
ngx_http_chunkin_is_chunked_encoding(ngx_http_request_t *r)
{
+ dd("is chunked encoding...");
+
return r->headers_in.transfer_encoding &&
r->headers_in.transfer_encoding->value.len >= 7 &&
ngx_strcasestrn(r->headers_in.transfer_encoding->value.data,
@@ -299,14 +301,28 @@ ngx_http_chunkin_resume_handler(ngx_http_request_t *r) {
conf = ngx_http_get_module_loc_conf(r, ngx_http_chunkin_filter_module);
- dd("method: %.*s", (int) r->method_name.len, r->method_name.data);
+ dd("method: %.*s (%d)", (int) r->method_name.len, r->method_name.data, (int) r->method);
if (!conf->enabled || r != r->main
- || ! ngx_http_chunkin_is_chunked_encoding(r->main))
+ || (r->method != NGX_HTTP_PUT && r->method != NGX_HTTP_POST))
+ {
+ dd("conf not enabled or in subrequest or not POST nor PUT requests");
+
+ return NGX_HTTP_LENGTH_REQUIRED;
+ }
+
+ if (r->method == NGX_HTTP_POST &&
+ ! ngx_http_chunkin_is_chunked_encoding(r->main))
{
+ dd("found POST request, but not chunked");
return NGX_HTTP_LENGTH_REQUIRED;
}
+ dd("chunked request test passed");
+
+ /* XXX just to fool the nginx core */
+ r->headers_in.content_length_n = 1;
+
ngx_http_chunkin_clear_transfer_encoding(r);
ctx = ngx_http_get_module_ctx(r, ngx_http_chunkin_filter_module);
View
@@ -301,4 +301,5 @@ Transfer-Encoding: chunked
"
--- response_body_like: 400 Bad Request
--- error_code: 400
+--- timeout: 10
View
@@ -50,6 +50,7 @@ close $out;
$s
--- response_body_eval
$::data
+--- timeout: 10
@@ -85,4 +86,5 @@ close $out;
$s
--- response_body eval
$::data
+--- timeout: 10
View
@@ -443,13 +443,14 @@ helloworld
--- config
chunkin on;
location /main {
+ echo_read_request_body;
echo_request_body;
}
--- request
PUT /main
-hello
---- response_body
-hello
+--- chunked_body eval
+["hello", "world"]
+--- response_body chomp
+helloworld
--- error_code: 200
---- SKIP

0 comments on commit c8547b8

Please sign in to comment.