400 bad request for http m-post method

Maxim Dounin mdounin at mdounin.ru
Wed Oct 5 15:25:45 UTC 2016


Hello!

On Wed, Oct 05, 2016 at 10:40:05AM -0400, nixcoder wrote:

> Hi,
> I'm getting the below error in nginx reverse proxy server. It seems the
> proxy server does not recognize the http method: "M-POST" ? Is there a way i
> can allow these incoming requests ?
> 
> nginx.1    | xxxx.xxx.xxx 10.x.xx.x - - [05/Oct/2016:10:31:57 +0000] "M-POST
> /cimom HTTP/1.1" 400 166 "-" "-"
> nginx.1    | xxxx.xxx.xxx 10.x.xx.x - - [05/Oct/2016:10:31:57 +0000] "M-POST
> /cimom HTTP/1.1" 400 166 "-" "-"

Only "A" .. "Z" and "_" are allowed in method names by nginx.
If you want to allow "M-POST", please try the following patch:

# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1475681003 -10800
#      Wed Oct 05 18:23:23 2016 +0300
# Node ID fb39836bb3708b26629eaea06fe1221e39daa253
# Parent  9b9ae81cd4f01ed60e7bab323d49b470cec69d9e
Allowed '-' in method names.

It is used at least by SOAP (M-POST method, defined by RFC 2774) and
by WebDAV versioning (VERSION-CONTROL and BASELINE-CONTROL methods,
defined by RFC 3253).

diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -149,7 +149,7 @@ ngx_http_parse_request_line(ngx_http_req
                 break;
             }
 
-            if ((ch < 'A' || ch > 'Z') && ch != '_') {
+            if ((ch < 'A' || ch > 'Z') && ch != '_' && ch != '-') {
                 return NGX_HTTP_PARSE_INVALID_METHOD;
             }
 
@@ -270,7 +270,7 @@ ngx_http_parse_request_line(ngx_http_req
                 break;
             }
 
-            if ((ch < 'A' || ch > 'Z') && ch != '_') {
+            if ((ch < 'A' || ch > 'Z') && ch != '_' && ch != '-') {
                 return NGX_HTTP_PARSE_INVALID_METHOD;
             }
 


-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list