1078
ngx_http_parse_uri(ngx_http_request_t *r)
1083
sw_after_slash_in_uri,
1090
for (p = r->uri_start; p != r->uri_end; p++) {
1102
state = sw_after_slash_in_uri;
1105
/* check "/.", "//", "%", and "\" (Win32) in URI */
1106
case sw_after_slash_in_uri:
1108
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
1109
state = sw_check_uri;
1115
r->space_in_uri = 1;
1116
state = sw_check_uri;
1137
r->args_start = p + 1;
1148
state = sw_check_uri;
1153
/* check "/", "%" and "\" (Win32) in URI */
1156
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
1163
if (r->uri_ext == p) {
1170
state = sw_after_slash_in_uri;
1176
r->space_in_uri = 1;
1181
state = sw_after_slash_in_uri;
1189
r->args_start = p + 1;
1205
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
1211
r->space_in_uri = 1;
931
1226
ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes)
933
1228
u_char c, ch, decoded, *p, *u;
1565
ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b,
1566
ngx_http_status_t *status)
1576
sw_first_major_digit,
1578
sw_first_minor_digit,
1581
sw_space_after_status,
1588
for (p = b->pos; p < b->last; p++) {
1637
state = sw_first_major_digit;
1644
/* the first digit of major HTTP version */
1645
case sw_first_major_digit:
1646
if (ch < '1' || ch > '9') {
1650
r->http_major = ch - '0';
1651
state = sw_major_digit;
1654
/* the major HTTP version or dot */
1655
case sw_major_digit:
1657
state = sw_first_minor_digit;
1661
if (ch < '0' || ch > '9') {
1665
r->http_major = r->http_major * 10 + ch - '0';
1668
/* the first digit of minor HTTP version */
1669
case sw_first_minor_digit:
1670
if (ch < '0' || ch > '9') {
1674
r->http_minor = ch - '0';
1675
state = sw_minor_digit;
1678
/* the minor HTTP version or the end of the request line */
1679
case sw_minor_digit:
1685
if (ch < '0' || ch > '9') {
1689
r->http_minor = r->http_minor * 10 + ch - '0';
1692
/* HTTP status code */
1698
if (ch < '0' || ch > '9') {
1702
status->code = status->code * 10 + ch - '0';
1704
if (++status->count == 3) {
1705
state = sw_space_after_status;
1706
status->start = p - 2;
1711
/* space or end of line */
1712
case sw_space_after_status:
1715
state = sw_status_text;
1717
case '.': /* IIS may send 403.1, 403.2, etc */
1718
state = sw_status_text;
1721
state = sw_almost_done;
1730
/* any text until end of line */
1731
case sw_status_text:
1734
state = sw_almost_done;
1742
/* end of status line */
1743
case sw_almost_done:
1744
status->end = p - 1;
1763
if (status->end == NULL) {
1767
status->http_version = r->http_major * 1000 + r->http_minor;
1768
r->state = sw_start;
1313
1775
ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
1314
1776
ngx_str_t *args, ngx_uint_t *flags)
1468
1904
return NGX_DECLINED;
1909
ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
1913
if (r->args.len == 0) {
1914
return NGX_DECLINED;
1918
last = p + r->args.len;
1920
for ( /* void */ ; p < last; p++) {
1922
/* we need '=' after name, so drop one char from last */
1924
p = ngx_strlcasestrn(p, last - 1, name, len - 1);
1927
return NGX_DECLINED;
1930
if ((p == r->args.data || *(p - 1) == '&') && *(p + len) == '=') {
1932
value->data = p + len + 1;
1934
p = ngx_strlchr(p, last, '&');
1937
p = r->args.data + r->args.len;
1940
value->len = p - value->data;
1946
return NGX_DECLINED;
1951
ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args)
1955
last = uri->data + uri->len;
1957
p = ngx_strlchr(uri->data, last, '?');
1960
uri->len = p - uri->data;
1962
args->len = last - p;
1972
ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b,
1973
ngx_http_chunked_t *ctx)
1981
sw_chunk_extension_almost_done,
1984
sw_after_data_almost_done,
1985
sw_last_chunk_extension,
1986
sw_last_chunk_extension_almost_done,
1988
sw_trailer_almost_done,
1990
sw_trailer_header_almost_done
1995
if (state == sw_chunk_data && ctx->size == 0) {
1996
state = sw_after_data;
2001
for (pos = b->pos; pos < b->last; pos++) {
2005
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
2006
"http chunked byte: %02Xd s:%d", ch, state);
2010
case sw_chunk_start:
2011
if (ch >= '0' && ch <= '9') {
2012
state = sw_chunk_size;
2013
ctx->size = ch - '0';
2017
c = (u_char) (ch | 0x20);
2019
if (c >= 'a' && c <= 'f') {
2020
state = sw_chunk_size;
2021
ctx->size = c - 'a' + 10;
2028
if (ch >= '0' && ch <= '9') {
2029
ctx->size = ctx->size * 16 + (ch - '0');
2033
c = (u_char) (ch | 0x20);
2035
if (c >= 'a' && c <= 'f') {
2036
ctx->size = ctx->size * 16 + (c - 'a' + 10);
2040
if (ctx->size == 0) {
2044
state = sw_last_chunk_extension_almost_done;
2052
state = sw_last_chunk_extension;
2063
state = sw_chunk_extension_almost_done;
2066
state = sw_chunk_data;
2071
state = sw_chunk_extension;
2079
case sw_chunk_extension:
2082
state = sw_chunk_extension_almost_done;
2085
state = sw_chunk_data;
2089
case sw_chunk_extension_almost_done:
2091
state = sw_chunk_data;
2103
state = sw_after_data_almost_done;
2106
state = sw_chunk_start;
2110
case sw_after_data_almost_done:
2112
state = sw_chunk_start;
2117
case sw_last_chunk_extension:
2120
state = sw_last_chunk_extension_almost_done;
2127
case sw_last_chunk_extension_almost_done:
2137
state = sw_trailer_almost_done;
2142
state = sw_trailer_header;
2146
case sw_trailer_almost_done:
2152
case sw_trailer_header:
2155
state = sw_trailer_header_almost_done;
2162
case sw_trailer_header_almost_done:
2179
case sw_chunk_start:
2180
ctx->length = 3 /* "0" LF LF */;
2183
ctx->length = 2 /* LF LF */
2184
+ (ctx->size ? ctx->size + 4 /* LF "0" LF LF */ : 0);
2186
case sw_chunk_extension:
2187
case sw_chunk_extension_almost_done:
2188
ctx->length = 1 /* LF */ + ctx->size + 4 /* LF "0" LF LF */;
2191
ctx->length = ctx->size + 4 /* LF "0" LF LF */;
2194
case sw_after_data_almost_done:
2195
ctx->length = 4 /* LF "0" LF LF */;
2197
case sw_last_chunk_extension:
2198
case sw_last_chunk_extension_almost_done:
2199
ctx->length = 2 /* LF LF */;
2202
case sw_trailer_almost_done:
2203
ctx->length = 1 /* LF */;
2205
case sw_trailer_header:
2206
case sw_trailer_header_almost_done:
2207
ctx->length = 2 /* LF LF */;