

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
4 messages in ru.sysoev.nginxRequests with full URIs| From | Sent On | Attachments |
|---|---|---|
| James Oakley | Sep 24, 2007 7:26 am | .patch |
| Igor Sysoev | Sep 24, 2007 12:43 pm | |
| James Oakley | Sep 25, 2007 10:44 am | |
| Igor Sysoev | Sep 26, 2007 4:29 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Requests with full URIs | Actions... |
|---|---|---|
| From: | James Oakley (jfun...@public.gmane.org) | |
| Date: | Sep 24, 2007 7:26:06 am | |
| List: | ru.sysoev.nginx | |
| Attachments: | ||
I've noticed that Nginx supports full URIs in requests, which is great, since I need to be able to respond to proxy requests.
I have noticed one problem, though. If I request a URI like so:
curl -x 127.0.0.1:80 http://www.google.com/
It works, and I get the correct response (I'm using empty_gif to test this)
If I leave the trailing slash, however, I get a 400 instead:
curl -x 127.0.0.1:80 http://www.google.com <html> <head><title>400 Bad Request</title></head> <body bgcolor="white"> <center><h1>400 Bad Request</h1></center> <hr><center>nginx/0.5.31</center> </body> </html>
I have attached a patch that appears to fix the problem, but I have only just started looking at the code and I have no idea whether this was the correct way to fix it.
-- James Oakley jfunk-WR+XdX2NAhvN+rMO2...@public.gmane.org
Index: nginx-0.5.31/src/http/ngx_http_parse.c
===================================================================
--- nginx-0.5.31.orig/src/http/ngx_http_parse.c 2007-09-24 10:45:34.000000000
-0300
+++ nginx-0.5.31/src/http/ngx_http_parse.c 2007-09-24 11:24:28.000000000 -0300
@@ -345,6 +345,13 @@ ngx_http_parse_request_line(ngx_http_req
r->uri_start = p;
state = sw_after_slash_in_uri;
break;
+ case ' ':
+ r->host_end = p;
+ r->uri.len = 1;
+ r->uri.data = (u_char *) "/";
+ r->uri_start = NULL;
+ state = sw_http_09;
+ break;
default:
r->host_end = p;
return NGX_HTTP_PARSE_INVALID_REQUEST;
Index: nginx-0.5.31/src/http/ngx_http_request.c
===================================================================
--- nginx-0.5.31.orig/src/http/ngx_http_request.c 2007-06-04 17:40:03.000000000
-0300
+++ nginx-0.5.31/src/http/ngx_http_request.c 2007-09-24 11:04:36.000000000 -0300
@@ -643,16 +643,20 @@ ngx_http_process_request_line(ngx_event_
if (r->args_start) {
r->uri.len = r->args_start - 1 - r->uri_start;
} else {
- r->uri.len = r->uri_end - r->uri_start;
+ if (r->uri_start) {
+ r->uri.len = r->uri_end - r->uri_start;
+ }
}
if (r->complex_uri || r->quoted_uri) {
- r->uri.data = ngx_palloc(r->pool, r->uri.len + 1);
- if (r->uri.data == NULL) {
- ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return;
+ if (r->uri_start) {
+ r->uri.data = ngx_palloc(r->pool, r->uri.len + 1);
+ if (r->uri.data == NULL) {
+ ngx_http_close_request(r,
NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
}
rc = ngx_http_parse_complex_uri(r); @@ -665,7 +669,9 @@ ngx_http_process_request_line(ngx_event_ }
} else { - r->uri.data = r->uri_start; + if (r->uri_start) { + r->uri.data = r->uri_start; + } }








.patch