aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_js_fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'nginx/ngx_js_fetch.c')
-rw-r--r--nginx/ngx_js_fetch.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/nginx/ngx_js_fetch.c b/nginx/ngx_js_fetch.c
index 45f2dc10..faa38aab 100644
--- a/nginx/ngx_js_fetch.c
+++ b/nginx/ngx_js_fetch.c
@@ -514,6 +514,7 @@ ngx_js_ext_fetch(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
ngx_url_t u;
ngx_uint_t i;
njs_bool_t has_host;
+ ngx_str_t method;
ngx_pool_t *pool;
njs_value_t *init, *value;
ngx_js_http_t *http;
@@ -674,6 +675,13 @@ ngx_js_ext_fetch(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
continue;
}
+ if (h[i].key.len == 14
+ && ngx_strncasecmp(h[i].key.data, (u_char *) "Content-Length", 14)
+ == 0)
+ {
+ continue;
+ }
+
njs_chb_append(&http->chain, h[i].key.data, h[i].key.len);
njs_chb_append_literal(&http->chain, ": ");
njs_chb_append(&http->chain, h[i].value.data, h[i].value.len);
@@ -693,7 +701,18 @@ ngx_js_ext_fetch(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
njs_chb_append(&http->chain, request.body.data, request.body.len);
} else {
- njs_chb_append_literal(&http->chain, CRLF);
+ method = request.method;
+
+ if ((method.len == 4
+ && (ngx_strncasecmp(method.data, (u_char *) "POST", 4) == 0))
+ || (method.len == 3
+ && ngx_strncasecmp(method.data, (u_char *) "PUT", 3) == 0))
+ {
+ njs_chb_append_literal(&http->chain, "Content-Length: 0" CRLF CRLF);
+
+ } else {
+ njs_chb_append_literal(&http->chain, CRLF);
+ }
}
if (u.addrs == NULL) {