nginx enforces case-sensitivity incorrectly

Matthew Dempsky matthew at dempsky.org
Tue Sep 15 04:21:48 MSD 2009


According to RFC 2616, the "HTTP" string literal in the HTTP-Version
part of the Request-Line is case-insensitive.  (Rationale: Section 2.1
says quoted string literals are case-insensitive unless otherwise
stated, and section 3.1 says nothing about case.)

However, nginx rejects "GET / http/1.1" as malformed.  The patch below
corrects this.

--- ngx_http_parse.c.orig	2009-09-15 00:10:48.000000000 +0000
+++ ngx_http_parse.c	2009-09-15 00:11:25.000000000 +0000
@@ -544,6 +544,7 @@
                 r->http_minor = 9;
                 goto done;
             case 'H':
+            case 'h':
                 r->http_protocol.data = p;
                 state = sw_http_H;
                 break;
@@ -555,6 +556,7 @@
         case sw_http_H:
             switch (ch) {
             case 'T':
+            case 't':
                 state = sw_http_HT;
                 break;
             default:
@@ -565,6 +567,7 @@
         case sw_http_HT:
             switch (ch) {
             case 'T':
+            case 't':
                 state = sw_http_HTT;
                 break;
             default:
@@ -575,6 +578,7 @@
         case sw_http_HTT:
             switch (ch) {
             case 'P':
+            case 'p':
                 state = sw_http_HTTP;
                 break;
             default:





More information about the nginx mailing list