summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_parse.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2013-03-20 10:36:57 +0000
committerValentin Bartenev <vbart@nginx.com>2013-03-20 10:36:57 +0000
commit2686cb44529462614a1846f29922bb68852dafb6 (patch)
treea46abd5e6cab450dbc23f220a424a296c0877e2b /src/http/ngx_http_parse.c
parentcf64a6c5361b23f1aa182e50537ebb4c6c34c453 (diff)
downloadnginx-2686cb44529462614a1846f29922bb68852dafb6.tar.gz
nginx-2686cb44529462614a1846f29922bb68852dafb6.tar.bz2
Preliminary experimental support for SPDY draft 2.
Diffstat (limited to 'src/http/ngx_http_parse.c')
-rw-r--r--src/http/ngx_http_parse.c148
1 files changed, 148 insertions, 0 deletions
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index a6ee74ecf..34b3b85d0 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -1075,6 +1075,154 @@ header_done:
ngx_int_t
+ngx_http_parse_uri(ngx_http_request_t *r)
+{
+ u_char *p, ch;
+ enum {
+ sw_start = 0,
+ sw_after_slash_in_uri,
+ sw_check_uri,
+ sw_uri
+ } state;
+
+ state = sw_start;
+
+ for (p = r->uri_start; p != r->uri_end; p++) {
+
+ ch = *p;
+
+ switch (state) {
+
+ case sw_start:
+
+ if (ch != '/') {
+ return NGX_ERROR;
+ }
+
+ state = sw_after_slash_in_uri;
+ break;
+
+ /* check "/.", "//", "%", and "\" (Win32) in URI */
+ case sw_after_slash_in_uri:
+
+ if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
+ state = sw_check_uri;
+ break;
+ }
+
+ switch (ch) {
+ case ' ':
+ r->space_in_uri = 1;
+ state = sw_check_uri;
+ break;
+ case '.':
+ r->complex_uri = 1;
+ state = sw_uri;
+ break;
+ case '%':
+ r->quoted_uri = 1;
+ state = sw_uri;
+ break;
+ case '/':
+ r->complex_uri = 1;
+ state = sw_uri;
+ break;
+#if (NGX_WIN32)
+ case '\\':
+ r->complex_uri = 1;
+ state = sw_uri;
+ break;
+#endif
+ case '?':
+ r->args_start = p + 1;
+ state = sw_uri;
+ break;
+ case '#':
+ r->complex_uri = 1;
+ state = sw_uri;
+ break;
+ case '+':
+ r->plus_in_uri = 1;
+ break;
+ default:
+ state = sw_check_uri;
+ break;
+ }
+ break;
+
+ /* check "/", "%" and "\" (Win32) in URI */
+ case sw_check_uri:
+
+ if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
+ break;
+ }
+
+ switch (ch) {
+ case '/':
+#if (NGX_WIN32)
+ if (r->uri_ext == p) {
+ r->complex_uri = 1;
+ state = sw_uri;
+ break;
+ }
+#endif
+ r->uri_ext = NULL;
+ state = sw_after_slash_in_uri;
+ break;
+ case '.':
+ r->uri_ext = p + 1;
+ break;
+ case ' ':
+ r->space_in_uri = 1;
+ break;
+#if (NGX_WIN32)
+ case '\\':
+ r->complex_uri = 1;
+ state = sw_after_slash_in_uri;
+ break;
+#endif
+ case '%':
+ r->quoted_uri = 1;
+ state = sw_uri;
+ break;
+ case '?':
+ r->args_start = p + 1;
+ state = sw_uri;
+ break;
+ case '#':
+ r->complex_uri = 1;
+ state = sw_uri;
+ break;
+ case '+':
+ r->plus_in_uri = 1;
+ break;
+ }
+ break;
+
+ /* URI */
+ case sw_uri:
+
+ if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
+ break;
+ }
+
+ switch (ch) {
+ case ' ':
+ r->space_in_uri = 1;
+ break;
+ case '#':
+ r->complex_uri = 1;
+ break;
+ }
+ break;
+ }
+ }
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes)
{
u_char c, ch, decoded, *p, *u;