Missing slash and error 400 / bad Request

Maxim Dounin mdounin at mdounin.ru
Tue Nov 3 16:50:16 MSK 2009


Hello!

On Tue, Nov 03, 2009 at 05:07:01AM -0800, cheinsow wrote:

> 
> I never tried with Apche, but it works with lightTPD. I got some other issues
> with lightTPD (essentially high CPU usage), that's why I'm trying to replace
> it with Nginx.

Actually, it doesn't matter how apache or lighty handle this.  
There are two basic points should be considered here:

1. What RFC 2616 says.

2. What real life says (i.e. if there are any clients using it).

RFC 2616 looks very clear here:

Request-Line   = Method SP Request-URI SP HTTP-Version CRLF
Request-URI    = "*" | absoluteURI | abs_path | authority

it adopts "absoluteURI", "abs_path" and "authority" definitions 
from RFC 2396:

absoluteURI   = scheme ":" ( hier_part | opaque_part )
abs_path      = "/"  path_segments

Obviously "index.html" isn't an absoluteURI (must contain ":"), and 
isn't an abs_path (must start with "/").

So "GET index.html HTTP/1.1" is only valid assuming "index.html" 
is authority.  On the other hand, RFC 2616 says in "5.1.2 
Request-URI":

% The authority form is only used by the CONNECT method (section 
% 9.9).

That is, "GET index.html HTTP/1.1" is invalid per RFC 2616.  It's 
not HTTP.  And nginx rightfully returns 400 here.

So we here back to question (2).  What client produced request in 
question?  Is it common enough to add compatibility shims and 
accept non-http requests from it?

Maxim Dounin


> 
> 
> 
> Igor Sysoev wrote:
> > 
> > On Tue, Nov 03, 2009 at 02:51:38AM -0800, cheinsow wrote:
> > 
> >> i'm trying to use Nginx as a reverse proxy, and i get some troubles due
> >> to a
> >> missing "/" in the HTTP header sant by a client application.
> >> The HTTP/GET header is "GET index.html HTTP/1.1" and it seems that it
> >> should
> >> be "GET /index.html HTTP/1.1". This causes an error 400 (nginx logs
> >> confirms
> >> this).
> >> 
> >> knowing that the client application cannot be modified, is their a way to
> >> configure Nginx so that it accepts this request ?
> > 
> > Do the client work with other web servers ?
> > Apache should return 400 error on such request too.
> > 
> > 
> > -- 
> > Igor Sysoev
> > http://sysoev.ru/en/
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://n2.nabble.com/Missing-slash-and-error-400-bad-Request-tp3937707p3938334.html
> Sent from the nginx mailing list archive at Nabble.com.
> 





More information about the nginx mailing list