Mercurial > hg > nginx-quic
annotate src/http/ngx_http_spdy_filter_module.c @ 5862:ecbb99aa0e12
Limit req: use complex value in limit_req_zone.
One intentional side effect of this change is that key is allowed only
in the first position. Previously, it was possible to specify the key
variable at any position, but that was never documented, and is contrary
with nginx configuration practice for positional parameters.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 24 Sep 2014 21:55:19 +0400 |
parents | a5886df87cbb |
children | 87ada3ba1392 |
rev | line source |
---|---|
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2 /* |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4 * Copyright (C) Valentin V. Bartenev |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5 */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
6 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
7 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
11 #include <nginx.h> |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
12 #include <ngx_http_spdy_module.h> |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
13 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
14 #include <zlib.h> |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
15 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
16 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
17 #define ngx_http_spdy_nv_nsize(h) (NGX_SPDY_NV_NLEN_SIZE + sizeof(h) - 1) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
18 #define ngx_http_spdy_nv_vsize(h) (NGX_SPDY_NV_VLEN_SIZE + sizeof(h) - 1) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
19 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
20 #define ngx_http_spdy_nv_write_num ngx_spdy_frame_write_uint32 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
21 #define ngx_http_spdy_nv_write_nlen ngx_spdy_frame_write_uint32 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
22 #define ngx_http_spdy_nv_write_vlen ngx_spdy_frame_write_uint32 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
23 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
24 #define ngx_http_spdy_nv_write_name(p, h) \ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
25 ngx_cpymem(ngx_http_spdy_nv_write_nlen(p, sizeof(h) - 1), h, sizeof(h) - 1) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
26 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
27 #define ngx_http_spdy_nv_write_val(p, h) \ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
28 ngx_cpymem(ngx_http_spdy_nv_write_vlen(p, sizeof(h) - 1), h, sizeof(h) - 1) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
29 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
30 |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
31 static ngx_chain_t *ngx_http_spdy_send_chain(ngx_connection_t *fc, |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
32 ngx_chain_t *in, off_t limit); |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
33 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
34 static ngx_inline ngx_int_t ngx_http_spdy_filter_send( |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
35 ngx_connection_t *fc, ngx_http_spdy_stream_t *stream); |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
36 static ngx_inline ngx_int_t ngx_http_spdy_flow_control( |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
37 ngx_http_spdy_connection_t *sc, ngx_http_spdy_stream_t *stream); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
38 static void ngx_http_spdy_waiting_queue(ngx_http_spdy_connection_t *sc, |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
39 ngx_http_spdy_stream_t *stream); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
40 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
41 static ngx_chain_t *ngx_http_spdy_filter_get_shadow( |
5517
9d1479234f3c
SPDY: fixed off_t/size_t type conversions on 32 bits platforms.
Valentin Bartenev <vbart@nginx.com>
parents:
5516
diff
changeset
|
42 ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, off_t offset, off_t size); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
43 static ngx_http_spdy_out_frame_t *ngx_http_spdy_filter_get_data_frame( |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
44 ngx_http_spdy_stream_t *stream, size_t len, ngx_chain_t *first, |
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
45 ngx_chain_t *last); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
46 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
47 static ngx_int_t ngx_http_spdy_syn_frame_handler( |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
48 ngx_http_spdy_connection_t *sc, ngx_http_spdy_out_frame_t *frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
49 static ngx_int_t ngx_http_spdy_data_frame_handler( |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
50 ngx_http_spdy_connection_t *sc, ngx_http_spdy_out_frame_t *frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
51 static ngx_inline void ngx_http_spdy_handle_frame( |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
52 ngx_http_spdy_stream_t *stream, ngx_http_spdy_out_frame_t *frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
53 static ngx_inline void ngx_http_spdy_handle_stream( |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
54 ngx_http_spdy_connection_t *sc, ngx_http_spdy_stream_t *stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
55 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
56 static void ngx_http_spdy_filter_cleanup(void *data); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
57 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
58 static ngx_int_t ngx_http_spdy_filter_init(ngx_conf_t *cf); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
59 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
60 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
61 static ngx_http_module_t ngx_http_spdy_filter_module_ctx = { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
62 NULL, /* preconfiguration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
63 ngx_http_spdy_filter_init, /* postconfiguration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
64 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
65 NULL, /* create main configuration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
66 NULL, /* init main configuration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
67 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
68 NULL, /* create server configuration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
69 NULL, /* merge server configuration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
70 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
71 NULL, /* create location configuration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
72 NULL /* merge location configuration */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
73 }; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
74 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
75 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
76 ngx_module_t ngx_http_spdy_filter_module = { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
77 NGX_MODULE_V1, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
78 &ngx_http_spdy_filter_module_ctx, /* module context */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
79 NULL, /* module directives */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
80 NGX_HTTP_MODULE, /* module type */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
81 NULL, /* init master */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
82 NULL, /* init module */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
83 NULL, /* init process */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
84 NULL, /* init thread */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
85 NULL, /* exit thread */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
86 NULL, /* exit process */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
87 NULL, /* exit master */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
88 NGX_MODULE_V1_PADDING |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
89 }; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
90 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
91 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
92 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
93 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
94 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
95 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
96 ngx_http_spdy_header_filter(ngx_http_request_t *r) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
97 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
98 int rc; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
99 size_t len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
100 u_char *p, *buf, *last; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
101 ngx_buf_t *b; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
102 ngx_str_t host; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
103 ngx_uint_t i, j, count, port; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
104 ngx_chain_t *cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
105 ngx_list_part_t *part, *pt; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
106 ngx_table_elt_t *header, *h; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
107 ngx_connection_t *c; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
108 ngx_http_cleanup_t *cln; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
109 ngx_http_core_loc_conf_t *clcf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
110 ngx_http_core_srv_conf_t *cscf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
111 ngx_http_spdy_stream_t *stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
112 ngx_http_spdy_out_frame_t *frame; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
113 ngx_http_spdy_connection_t *sc; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
114 struct sockaddr_in *sin; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
115 #if (NGX_HAVE_INET6) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
116 struct sockaddr_in6 *sin6; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
117 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
118 u_char addr[NGX_SOCKADDR_STRLEN]; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
119 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
120 if (!r->spdy_stream) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
121 return ngx_http_next_header_filter(r); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
122 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
123 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
124 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
125 "spdy header filter"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
126 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
127 if (r->header_sent) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
128 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
129 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
130 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
131 r->header_sent = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
132 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
133 if (r != r->main) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
134 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
135 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
136 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
137 c = r->connection; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
138 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
139 if (r->method == NGX_HTTP_HEAD) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
140 r->header_only = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
141 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
142 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
143 switch (r->headers_out.status) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
144 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
145 case NGX_HTTP_OK: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
146 case NGX_HTTP_PARTIAL_CONTENT: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
147 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
148 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
149 case NGX_HTTP_NOT_MODIFIED: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
150 r->header_only = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
151 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
152 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
153 case NGX_HTTP_NO_CONTENT: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
154 r->header_only = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
155 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
156 ngx_str_null(&r->headers_out.content_type); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
157 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
158 r->headers_out.content_length = NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
159 r->headers_out.content_length_n = -1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
160 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
161 /* fall through */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
162 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
163 default: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
164 r->headers_out.last_modified_time = -1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
165 r->headers_out.last_modified = NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
166 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
167 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
168 len = NGX_SPDY_NV_NUM_SIZE |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
169 + ngx_http_spdy_nv_nsize(":version") |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
170 + ngx_http_spdy_nv_vsize("HTTP/1.1") |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
171 + ngx_http_spdy_nv_nsize(":status") |
5249
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
172 + (r->headers_out.status_line.len |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
173 ? NGX_SPDY_NV_VLEN_SIZE + r->headers_out.status_line.len |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
174 : ngx_http_spdy_nv_vsize("418")); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
175 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
176 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
177 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
178 if (r->headers_out.server == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
179 len += ngx_http_spdy_nv_nsize("server"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
180 len += clcf->server_tokens ? ngx_http_spdy_nv_vsize(NGINX_VER) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
181 : ngx_http_spdy_nv_vsize("nginx"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
182 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
183 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
184 if (r->headers_out.date == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
185 len += ngx_http_spdy_nv_nsize("date") |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
186 + ngx_http_spdy_nv_vsize("Wed, 31 Dec 1986 10:00:00 GMT"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
187 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
188 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
189 if (r->headers_out.content_type.len) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
190 len += ngx_http_spdy_nv_nsize("content-type") |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
191 + NGX_SPDY_NV_VLEN_SIZE + r->headers_out.content_type.len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
192 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
193 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
194 && r->headers_out.charset.len) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
195 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
196 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
197 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
198 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
199 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
200 if (r->headers_out.content_length == NULL |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
201 && r->headers_out.content_length_n >= 0) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
202 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
203 len += ngx_http_spdy_nv_nsize("content-length") |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
204 + NGX_SPDY_NV_VLEN_SIZE + NGX_OFF_T_LEN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
205 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
206 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
207 if (r->headers_out.last_modified == NULL |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
208 && r->headers_out.last_modified_time != -1) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
209 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
210 len += ngx_http_spdy_nv_nsize("last-modified") |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
211 + ngx_http_spdy_nv_vsize("Wed, 31 Dec 1986 10:00:00 GMT"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
212 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
213 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
214 if (r->headers_out.location |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
215 && r->headers_out.location->value.len |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
216 && r->headers_out.location->value.data[0] == '/') |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
217 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
218 r->headers_out.location->hash = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
219 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
220 if (clcf->server_name_in_redirect) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
221 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
222 host = cscf->server_name; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
223 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
224 } else if (r->headers_in.server.len) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
225 host = r->headers_in.server; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
226 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
227 } else { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
228 host.len = NGX_SOCKADDR_STRLEN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
229 host.data = addr; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
230 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
231 if (ngx_connection_local_sockaddr(c, &host, 0) != NGX_OK) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
232 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
233 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
234 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
235 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
236 switch (c->local_sockaddr->sa_family) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
237 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
238 #if (NGX_HAVE_INET6) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
239 case AF_INET6: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
240 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
241 port = ntohs(sin6->sin6_port); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
242 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
243 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
244 #if (NGX_HAVE_UNIX_DOMAIN) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
245 case AF_UNIX: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
246 port = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
247 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
248 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
249 default: /* AF_INET */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
250 sin = (struct sockaddr_in *) c->local_sockaddr; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
251 port = ntohs(sin->sin_port); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
252 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
253 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
254 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
255 len += ngx_http_spdy_nv_nsize("location") |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
256 + ngx_http_spdy_nv_vsize("https://") |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
257 + host.len |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
258 + r->headers_out.location->value.len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
259 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
260 if (clcf->port_in_redirect) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
261 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
262 #if (NGX_HTTP_SSL) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
263 if (c->ssl) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
264 port = (port == 443) ? 0 : port; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
265 else |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
266 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
267 port = (port == 80) ? 0 : port; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
268 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
269 } else { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
270 port = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
271 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
272 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
273 if (port) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
274 len += sizeof(":65535") - 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
275 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
276 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
277 } else { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
278 ngx_str_null(&host); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
279 port = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
280 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
281 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
282 part = &r->headers_out.headers.part; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
283 header = part->elts; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
284 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
285 for (i = 0; /* void */; i++) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
286 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
287 if (i >= part->nelts) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
288 if (part->next == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
289 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
290 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
291 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
292 part = part->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
293 header = part->elts; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
294 i = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
295 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
296 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
297 if (header[i].hash == 0) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
298 continue; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
299 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
300 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
301 len += NGX_SPDY_NV_NLEN_SIZE + header[i].key.len |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
302 + NGX_SPDY_NV_VLEN_SIZE + header[i].value.len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
303 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
304 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
305 buf = ngx_alloc(len, r->pool->log); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
306 if (buf == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
307 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
308 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
309 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
310 last = buf + NGX_SPDY_NV_NUM_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
311 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
312 last = ngx_http_spdy_nv_write_name(last, ":version"); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
313 last = ngx_http_spdy_nv_write_val(last, "HTTP/1.1"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
314 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
315 last = ngx_http_spdy_nv_write_name(last, ":status"); |
5249
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
316 |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
317 if (r->headers_out.status_line.len) { |
5251
4ef49081ef4c
SPDY: fixed code style, no functional changes.
Valentin Bartenev <vbart@nginx.com>
parents:
5249
diff
changeset
|
318 last = ngx_http_spdy_nv_write_vlen(last, |
4ef49081ef4c
SPDY: fixed code style, no functional changes.
Valentin Bartenev <vbart@nginx.com>
parents:
5249
diff
changeset
|
319 r->headers_out.status_line.len); |
5249
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
320 last = ngx_cpymem(last, r->headers_out.status_line.data, |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
321 r->headers_out.status_line.len); |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
322 } else { |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
323 last = ngx_http_spdy_nv_write_vlen(last, 3); |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
324 last = ngx_sprintf(last, "%03ui", r->headers_out.status); |
725fb71ab1a6
SPDY: pass through the full status when available.
Jim Radford <radford@galvanix.com>
parents:
5242
diff
changeset
|
325 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
326 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
327 count = 2; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
328 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
329 if (r->headers_out.server == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
330 last = ngx_http_spdy_nv_write_name(last, "server"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
331 last = clcf->server_tokens |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
332 ? ngx_http_spdy_nv_write_val(last, NGINX_VER) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
333 : ngx_http_spdy_nv_write_val(last, "nginx"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
334 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
335 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
336 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
337 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
338 if (r->headers_out.date == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
339 last = ngx_http_spdy_nv_write_name(last, "date"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
340 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
341 last = ngx_http_spdy_nv_write_vlen(last, ngx_cached_http_time.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
342 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
343 last = ngx_cpymem(last, ngx_cached_http_time.data, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
344 ngx_cached_http_time.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
345 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
346 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
347 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
348 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
349 if (r->headers_out.content_type.len) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
350 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
351 last = ngx_http_spdy_nv_write_name(last, "content-type"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
352 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
353 p = last + NGX_SPDY_NV_VLEN_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
354 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
355 last = ngx_cpymem(p, r->headers_out.content_type.data, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
356 r->headers_out.content_type.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
357 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
358 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
359 && r->headers_out.charset.len) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
360 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
361 last = ngx_cpymem(last, "; charset=", sizeof("; charset=") - 1); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
362 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
363 last = ngx_cpymem(last, r->headers_out.charset.data, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
364 r->headers_out.charset.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
365 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
366 /* update r->headers_out.content_type for possible logging */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
367 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
368 r->headers_out.content_type.len = last - p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
369 r->headers_out.content_type.data = p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
370 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
371 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
372 (void) ngx_http_spdy_nv_write_vlen(p - NGX_SPDY_NV_VLEN_SIZE, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
373 r->headers_out.content_type.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
374 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
375 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
376 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
377 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
378 if (r->headers_out.content_length == NULL |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
379 && r->headers_out.content_length_n >= 0) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
380 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
381 last = ngx_http_spdy_nv_write_name(last, "content-length"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
382 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
383 p = last + NGX_SPDY_NV_VLEN_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
384 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
385 last = ngx_sprintf(p, "%O", r->headers_out.content_length_n); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
386 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
387 (void) ngx_http_spdy_nv_write_vlen(p - NGX_SPDY_NV_VLEN_SIZE, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
388 last - p); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
389 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
390 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
391 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
392 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
393 if (r->headers_out.last_modified == NULL |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
394 && r->headers_out.last_modified_time != -1) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
395 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
396 last = ngx_http_spdy_nv_write_name(last, "last-modified"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
397 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
398 p = last + NGX_SPDY_NV_VLEN_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
399 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
400 last = ngx_http_time(p, r->headers_out.last_modified_time); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
401 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
402 (void) ngx_http_spdy_nv_write_vlen(p - NGX_SPDY_NV_VLEN_SIZE, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
403 last - p); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
404 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
405 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
406 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
407 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
408 if (host.data) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
409 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
410 last = ngx_http_spdy_nv_write_name(last, "location"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
411 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
412 p = last + NGX_SPDY_NV_VLEN_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
413 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
414 last = ngx_cpymem(p, "http", sizeof("http") - 1); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
415 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
416 #if (NGX_HTTP_SSL) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
417 if (c->ssl) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
418 *last++ ='s'; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
419 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
420 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
421 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
422 *last++ = ':'; *last++ = '/'; *last++ = '/'; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
423 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
424 last = ngx_cpymem(last, host.data, host.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
425 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
426 if (port) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
427 last = ngx_sprintf(last, ":%ui", port); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
428 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
429 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
430 last = ngx_cpymem(last, r->headers_out.location->value.data, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
431 r->headers_out.location->value.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
432 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
433 /* update r->headers_out.location->value for possible logging */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
434 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
435 r->headers_out.location->value.len = last - p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
436 r->headers_out.location->value.data = p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
437 ngx_str_set(&r->headers_out.location->key, "location"); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
438 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
439 (void) ngx_http_spdy_nv_write_vlen(p - NGX_SPDY_NV_VLEN_SIZE, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
440 r->headers_out.location->value.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
441 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
442 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
443 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
444 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
445 part = &r->headers_out.headers.part; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
446 header = part->elts; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
447 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
448 for (i = 0; /* void */; i++) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
449 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
450 if (i >= part->nelts) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
451 if (part->next == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
452 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
453 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
454 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
455 part = part->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
456 header = part->elts; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
457 i = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
458 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
459 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
460 if (header[i].hash == 0 || header[i].hash == 2) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
461 continue; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
462 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
463 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
464 last = ngx_http_spdy_nv_write_nlen(last, header[i].key.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
465 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
466 ngx_strlow(last, header[i].key.data, header[i].key.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
467 last += header[i].key.len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
468 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
469 p = last + NGX_SPDY_NV_VLEN_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
470 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
471 last = ngx_cpymem(p, header[i].value.data, header[i].value.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
472 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
473 pt = part; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
474 h = header; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
475 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
476 for (j = i + 1; /* void */; j++) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
477 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
478 if (j >= pt->nelts) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
479 if (pt->next == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
480 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
481 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
482 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
483 pt = pt->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
484 h = pt->elts; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
485 j = 0; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
486 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
487 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
488 if (h[j].hash == 0 || h[j].hash == 2 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
489 || h[j].key.len != header[i].key.len |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
490 || ngx_strncasecmp(header[i].key.data, h[j].key.data, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
491 header[i].key.len)) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
492 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
493 continue; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
494 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
495 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
496 *last++ = '\0'; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
497 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
498 last = ngx_cpymem(last, h[j].value.data, h[j].value.len); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
499 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
500 h[j].hash = 2; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
501 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
502 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
503 (void) ngx_http_spdy_nv_write_vlen(p - NGX_SPDY_NV_VLEN_SIZE, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
504 last - p); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
505 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
506 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
507 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
508 |
5242
5776804fff04
SPDY: use proper macros for value length and headers counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5121
diff
changeset
|
509 (void) ngx_http_spdy_nv_write_num(buf, count); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
510 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
511 stream = r->spdy_stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
512 sc = stream->connection; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
513 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
514 len = last - buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
515 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
516 b = ngx_create_temp_buf(r->pool, NGX_SPDY_FRAME_HEADER_SIZE |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
517 + NGX_SPDY_SYN_REPLY_SIZE |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
518 + deflateBound(&sc->zstream_out, len)); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
519 if (b == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
520 ngx_free(buf); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
521 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
522 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
523 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
524 b->last += NGX_SPDY_FRAME_HEADER_SIZE + NGX_SPDY_SYN_REPLY_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
525 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
526 sc->zstream_out.next_in = buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
527 sc->zstream_out.avail_in = len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
528 sc->zstream_out.next_out = b->last; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
529 sc->zstream_out.avail_out = b->end - b->last; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
530 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
531 rc = deflate(&sc->zstream_out, Z_SYNC_FLUSH); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
532 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
533 ngx_free(buf); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
534 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
535 if (rc != Z_OK) { |
5693
701d6e17e42c
SPDY: improved logging.
Valentin Bartenev <vbart@nginx.com>
parents:
5644
diff
changeset
|
536 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "deflate() failed: %d", rc); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
537 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
538 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
539 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
540 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
541 "spdy deflate out: ni:%p no:%p ai:%ud ao:%ud rc:%d", |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
542 sc->zstream_out.next_in, sc->zstream_out.next_out, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
543 sc->zstream_out.avail_in, sc->zstream_out.avail_out, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
544 rc); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
545 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
546 b->last = sc->zstream_out.next_out; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
547 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
548 p = b->pos; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
549 p = ngx_spdy_frame_write_head(p, NGX_SPDY_SYN_REPLY); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
550 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
551 len = b->last - b->pos; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
552 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
553 r->header_size = len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
554 |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
555 len -= NGX_SPDY_FRAME_HEADER_SIZE; |
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
556 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
557 if (r->header_only) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
558 b->last_buf = 1; |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
559 p = ngx_spdy_frame_write_flags_and_len(p, NGX_SPDY_FLAG_FIN, len); |
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
560 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
561 } else { |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
562 p = ngx_spdy_frame_write_flags_and_len(p, 0, len); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
563 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
564 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
565 (void) ngx_spdy_frame_write_sid(p, stream->id); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
566 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
567 cl = ngx_alloc_chain_link(r->pool); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
568 if (cl == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
569 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
570 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
571 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
572 cl->buf = b; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
573 cl->next = NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
574 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
575 frame = ngx_palloc(r->pool, sizeof(ngx_http_spdy_out_frame_t)); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
576 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
577 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
578 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
579 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
580 frame->first = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
581 frame->last = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
582 frame->handler = ngx_http_spdy_syn_frame_handler; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
583 frame->stream = stream; |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
584 frame->length = len; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
585 frame->priority = stream->priority; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
586 frame->blocked = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
587 frame->fin = r->header_only; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
588 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
589 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, stream->request->connection->log, 0, |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
590 "spdy:%ui create SYN_REPLY frame %p: len:%uz", |
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
591 stream->id, frame, frame->length); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
592 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
593 ngx_http_spdy_queue_blocked_frame(sc, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
594 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
595 cln = ngx_http_cleanup_add(r, 0); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
596 if (cln == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
597 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
598 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
599 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
600 cln->handler = ngx_http_spdy_filter_cleanup; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
601 cln->data = stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
602 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
603 stream->queued = 1; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
604 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
605 c->send_chain = ngx_http_spdy_send_chain; |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
606 c->need_last_buf = 1; |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
607 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
608 return ngx_http_spdy_filter_send(c, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
609 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
610 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
611 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
612 static ngx_chain_t * |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
613 ngx_http_spdy_send_chain(ngx_connection_t *fc, ngx_chain_t *in, off_t limit) |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
614 { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
615 off_t size, offset; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
616 size_t rest, frame_size; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
617 ngx_chain_t *cl, *out, **ln; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
618 ngx_http_request_t *r; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
619 ngx_http_spdy_stream_t *stream; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
620 ngx_http_spdy_loc_conf_t *slcf; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
621 ngx_http_spdy_out_frame_t *frame; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
622 ngx_http_spdy_connection_t *sc; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
623 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
624 r = fc->data; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
625 stream = r->spdy_stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
626 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
627 #if (NGX_SUPPRESS_WARN) |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
628 size = 0; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
629 #endif |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
630 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
631 while (in) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
632 size = ngx_buf_size(in->buf); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
633 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
634 if (size || in->buf->last_buf) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
635 break; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
636 } |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
637 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
638 in = in->next; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
639 } |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
640 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
641 if (in == NULL) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
642 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
643 if (stream->queued) { |
5512
9fffc0c46e5c
SPDY: fixed possible premature close of stream.
Valentin Bartenev <vbart@nginx.com>
parents:
5511
diff
changeset
|
644 fc->write->delayed = 1; |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
645 } else { |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
646 fc->buffered &= ~NGX_SPDY_BUFFERED; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
647 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
648 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
649 return NULL; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
650 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
651 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
652 sc = stream->connection; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
653 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
654 if (size && ngx_http_spdy_flow_control(sc, stream) == NGX_DECLINED) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
655 fc->write->delayed = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
656 return in; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
657 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
658 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
659 if (limit == 0 || limit > (off_t) sc->send_window) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
660 limit = sc->send_window; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
661 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
662 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
663 if (limit > stream->send_window) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
664 limit = (stream->send_window > 0) ? stream->send_window : 0; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
665 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
666 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
667 if (in->buf->tag == (ngx_buf_tag_t) &ngx_http_spdy_filter_get_shadow) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
668 cl = ngx_alloc_chain_link(r->pool); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
669 if (cl == NULL) { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
670 return NGX_CHAIN_ERROR; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
671 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
672 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
673 cl->buf = in->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
674 in->buf = cl->buf->shadow; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
675 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
676 offset = ngx_buf_in_memory(in->buf) |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
677 ? (cl->buf->pos - in->buf->pos) |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
678 : (cl->buf->file_pos - in->buf->file_pos); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
679 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
680 cl->next = stream->free_bufs; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
681 stream->free_bufs = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
682 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
683 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
684 offset = 0; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
685 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
686 |
5516
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
687 #if (NGX_SUPPRESS_WARN) |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
688 cl = NULL; |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
689 #endif |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
690 |
5515
e5fb14e85040
SPDY: added the "spdy_chunk_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
5514
diff
changeset
|
691 slcf = ngx_http_get_module_loc_conf(r, ngx_http_spdy_module); |
e5fb14e85040
SPDY: added the "spdy_chunk_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
5514
diff
changeset
|
692 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
693 frame_size = (limit <= (off_t) slcf->chunk_size) ? (size_t) limit |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
694 : slcf->chunk_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
695 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
696 for ( ;; ) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
697 ln = &out; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
698 rest = frame_size; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
699 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
700 while ((off_t) rest >= size) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
701 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
702 if (offset) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
703 cl = ngx_http_spdy_filter_get_shadow(stream, in->buf, |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
704 offset, size); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
705 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
706 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
707 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
708 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
709 offset = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
710 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
711 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
712 cl = ngx_alloc_chain_link(r->pool); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
713 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
714 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
715 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
716 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
717 cl->buf = in->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
718 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
719 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
720 *ln = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
721 ln = &cl->next; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
722 |
5517
9d1479234f3c
SPDY: fixed off_t/size_t type conversions on 32 bits platforms.
Valentin Bartenev <vbart@nginx.com>
parents:
5516
diff
changeset
|
723 rest -= (size_t) size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
724 in = in->next; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
725 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
726 if (in == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
727 frame_size -= rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
728 rest = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
729 break; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
730 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
731 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
732 size = ngx_buf_size(in->buf); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
733 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
734 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
735 if (rest) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
736 cl = ngx_http_spdy_filter_get_shadow(stream, in->buf, |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
737 offset, rest); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
738 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
739 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
740 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
741 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
742 cl->buf->flush = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
743 cl->buf->last_buf = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
744 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
745 *ln = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
746 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
747 offset += rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
748 size -= rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
749 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
750 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
751 frame = ngx_http_spdy_filter_get_data_frame(stream, frame_size, |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
752 out, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
753 if (frame == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
754 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
755 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
756 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
757 ngx_http_spdy_queue_frame(sc, frame); |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
758 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
759 sc->send_window -= frame_size; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
760 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
761 stream->send_window -= frame_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
762 stream->queued++; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
763 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
764 if (in == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
765 break; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
766 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
767 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
768 limit -= frame_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
769 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
770 if (limit == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
771 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
772 } |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
773 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
774 if (limit < (off_t) slcf->chunk_size) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
775 frame_size = (size_t) limit; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
776 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
777 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
778 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
779 if (offset) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
780 cl = ngx_http_spdy_filter_get_shadow(stream, in->buf, offset, size); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
781 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
782 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
783 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
784 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
785 in->buf = cl->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
786 ngx_free_chain(r->pool, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
787 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
788 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
789 if (ngx_http_spdy_filter_send(fc, stream) == NGX_ERROR) { |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
790 return NGX_CHAIN_ERROR; |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
791 } |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
792 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
793 if (in && ngx_http_spdy_flow_control(sc, stream) == NGX_DECLINED) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
794 fc->write->delayed = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
795 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
796 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
797 return in; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
798 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
799 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
800 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
801 static ngx_chain_t * |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
802 ngx_http_spdy_filter_get_shadow(ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, |
5517
9d1479234f3c
SPDY: fixed off_t/size_t type conversions on 32 bits platforms.
Valentin Bartenev <vbart@nginx.com>
parents:
5516
diff
changeset
|
803 off_t offset, off_t size) |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
804 { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
805 ngx_buf_t *chunk; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
806 ngx_chain_t *cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
807 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
808 cl = ngx_chain_get_free_buf(stream->request->pool, &stream->free_bufs); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
809 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
810 return NULL; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
811 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
812 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
813 chunk = cl->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
814 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
815 ngx_memcpy(chunk, buf, sizeof(ngx_buf_t)); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
816 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
817 chunk->tag = (ngx_buf_tag_t) &ngx_http_spdy_filter_get_shadow; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
818 chunk->shadow = buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
819 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
820 if (ngx_buf_in_memory(chunk)) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
821 chunk->pos += offset; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
822 chunk->last = chunk->pos + size; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
823 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
824 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
825 if (chunk->in_file) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
826 chunk->file_pos += offset; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
827 chunk->file_last = chunk->file_pos + size; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
828 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
829 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
830 return cl; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
831 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
832 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
833 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
834 static ngx_http_spdy_out_frame_t * |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
835 ngx_http_spdy_filter_get_data_frame(ngx_http_spdy_stream_t *stream, |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
836 size_t len, ngx_chain_t *first, ngx_chain_t *last) |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
837 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
838 u_char *p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
839 ngx_buf_t *buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
840 ngx_uint_t flags; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
841 ngx_chain_t *cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
842 ngx_http_spdy_out_frame_t *frame; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
843 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
844 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
845 frame = stream->free_frames; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
846 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
847 if (frame) { |
5528
d5de6c25b759
SPDY: use frame->next pointer to chain free frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5517
diff
changeset
|
848 stream->free_frames = frame->next; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
849 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
850 } else { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
851 frame = ngx_palloc(stream->request->pool, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
852 sizeof(ngx_http_spdy_out_frame_t)); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
853 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
854 return NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
855 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
856 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
857 |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
858 flags = last->buf->last_buf ? NGX_SPDY_FLAG_FIN : 0; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
859 |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
860 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, stream->request->connection->log, 0, |
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
861 "spdy:%ui create DATA frame %p: len:%uz flags:%ui", |
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
862 stream->id, frame, len, flags); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
863 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
864 cl = ngx_chain_get_free_buf(stream->request->pool, |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
865 &stream->free_data_headers); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
866 if (cl == NULL) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
867 return NULL; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
868 } |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
869 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
870 buf = cl->buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
871 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
872 if (buf->start) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
873 p = buf->start; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
874 buf->pos = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
875 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
876 p += NGX_SPDY_SID_SIZE; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
877 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
878 (void) ngx_spdy_frame_write_flags_and_len(p, flags, len); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
879 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
880 } else { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
881 p = ngx_palloc(stream->request->pool, NGX_SPDY_FRAME_HEADER_SIZE); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
882 if (p == NULL) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
883 return NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
884 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
885 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
886 buf->pos = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
887 buf->start = p; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
888 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
889 p = ngx_spdy_frame_write_sid(p, stream->id); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
890 p = ngx_spdy_frame_write_flags_and_len(p, flags, len); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
891 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
892 buf->last = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
893 buf->end = p; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
894 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
895 buf->tag = (ngx_buf_tag_t) &ngx_http_spdy_filter_get_data_frame; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
896 buf->memory = 1; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
897 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
898 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
899 cl->next = first; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
900 first = cl; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
901 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
902 last->buf->flush = 1; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
903 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
904 frame->first = first; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
905 frame->last = last; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
906 frame->handler = ngx_http_spdy_data_frame_handler; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
907 frame->stream = stream; |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
908 frame->length = len; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
909 frame->priority = stream->priority; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
910 frame->blocked = 0; |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
911 frame->fin = last->buf->last_buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
912 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
913 return frame; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
914 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
915 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
916 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
917 static ngx_inline ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
918 ngx_http_spdy_filter_send(ngx_connection_t *fc, ngx_http_spdy_stream_t *stream) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
919 { |
5493
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
920 stream->blocked = 1; |
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
921 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
922 if (ngx_http_spdy_send_output_queue(stream->connection) == NGX_ERROR) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
923 fc->error = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
924 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
925 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
926 |
5493
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
927 stream->blocked = 0; |
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
928 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
929 if (stream->queued) { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
930 fc->buffered |= NGX_SPDY_BUFFERED; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
931 fc->write->delayed = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
932 return NGX_AGAIN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
933 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
934 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
935 fc->buffered &= ~NGX_SPDY_BUFFERED; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
936 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
937 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
938 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
939 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
940 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
941 static ngx_inline ngx_int_t |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
942 ngx_http_spdy_flow_control(ngx_http_spdy_connection_t *sc, |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
943 ngx_http_spdy_stream_t *stream) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
944 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
945 if (stream->send_window <= 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
946 stream->exhausted = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
947 return NGX_DECLINED; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
948 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
949 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
950 if (sc->send_window == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
951 ngx_http_spdy_waiting_queue(sc, stream); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
952 return NGX_DECLINED; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
953 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
954 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
955 return NGX_OK; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
956 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
957 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
958 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
959 static void |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
960 ngx_http_spdy_waiting_queue(ngx_http_spdy_connection_t *sc, |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
961 ngx_http_spdy_stream_t *stream) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
962 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
963 ngx_queue_t *q; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
964 ngx_http_spdy_stream_t *s; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
965 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
966 if (stream->handled) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
967 return; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
968 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
969 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
970 stream->handled = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
971 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
972 for (q = ngx_queue_last(&sc->waiting); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
973 q != ngx_queue_sentinel(&sc->waiting); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
974 q = ngx_queue_prev(q)) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
975 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
976 s = ngx_queue_data(q, ngx_http_spdy_stream_t, queue); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
977 |
5576
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
978 /* |
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
979 * NB: higher values represent lower priorities. |
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
980 */ |
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
981 if (stream->priority >= s->priority) { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
982 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
983 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
984 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
985 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
986 ngx_queue_insert_after(q, &stream->queue); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
987 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
988 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
989 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
990 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
991 ngx_http_spdy_syn_frame_handler(ngx_http_spdy_connection_t *sc, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
992 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
993 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
994 ngx_buf_t *buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
995 ngx_http_spdy_stream_t *stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
996 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
997 buf = frame->first->buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
998 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
999 if (buf->pos != buf->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1000 return NGX_AGAIN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1001 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1002 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1003 stream = frame->stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1004 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1005 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1006 "spdy:%ui SYN_REPLY frame %p was sent", stream->id, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1007 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1008 ngx_free_chain(stream->request->pool, frame->first); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1009 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1010 ngx_http_spdy_handle_frame(stream, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1011 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1012 ngx_http_spdy_handle_stream(sc, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1013 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1014 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1015 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1016 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1017 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1018 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1019 ngx_http_spdy_data_frame_handler(ngx_http_spdy_connection_t *sc, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1020 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1021 { |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1022 ngx_buf_t *buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1023 ngx_chain_t *cl, *ln; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1024 ngx_http_spdy_stream_t *stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1025 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1026 stream = frame->stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1027 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1028 cl = frame->first; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1029 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1030 if (cl->buf->tag == (ngx_buf_tag_t) &ngx_http_spdy_filter_get_data_frame) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1031 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1032 if (cl->buf->pos != cl->buf->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1033 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1034 "spdy:%ui DATA frame %p was sent partially", |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1035 stream->id, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1036 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1037 return NGX_AGAIN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1038 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1039 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1040 ln = cl->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1041 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1042 cl->next = stream->free_data_headers; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1043 stream->free_data_headers = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1044 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1045 if (cl == frame->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1046 goto done; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1047 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1048 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1049 cl = ln; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1050 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1051 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1052 for ( ;; ) { |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1053 if (cl->buf->tag == (ngx_buf_tag_t) &ngx_http_spdy_filter_get_shadow) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1054 buf = cl->buf->shadow; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1055 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1056 if (ngx_buf_in_memory(buf)) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1057 buf->pos = cl->buf->pos; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1058 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1059 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1060 if (buf->in_file) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1061 buf->file_pos = cl->buf->file_pos; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1062 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1063 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1064 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1065 if (ngx_buf_size(cl->buf) != 0) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1066 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1067 if (cl != frame->first) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1068 frame->first = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1069 ngx_http_spdy_handle_stream(sc, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1070 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1071 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1072 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1073 "spdy:%ui DATA frame %p was sent partially", |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1074 stream->id, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1075 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1076 return NGX_AGAIN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1077 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1078 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1079 ln = cl->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1080 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1081 if (cl->buf->tag == (ngx_buf_tag_t) &ngx_http_spdy_filter_get_shadow) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1082 cl->next = stream->free_bufs; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1083 stream->free_bufs = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1084 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1085 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1086 ngx_free_chain(stream->request->pool, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1087 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1088 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1089 if (cl == frame->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1090 goto done; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1091 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1092 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1093 cl = ln; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1094 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1095 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1096 done: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1097 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1098 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1099 "spdy:%ui DATA frame %p was sent", stream->id, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1100 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1101 stream->request->header_size += NGX_SPDY_FRAME_HEADER_SIZE; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1102 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1103 ngx_http_spdy_handle_frame(stream, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1104 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1105 ngx_http_spdy_handle_stream(sc, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1106 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1107 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1108 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1109 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1110 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1111 static ngx_inline void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1112 ngx_http_spdy_handle_frame(ngx_http_spdy_stream_t *stream, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1113 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1114 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1115 ngx_http_request_t *r; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1116 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1117 r = stream->request; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1118 |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
1119 r->connection->sent += NGX_SPDY_FRAME_HEADER_SIZE + frame->length; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1120 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1121 if (frame->fin) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1122 stream->out_closed = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1123 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1124 |
5528
d5de6c25b759
SPDY: use frame->next pointer to chain free frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5517
diff
changeset
|
1125 frame->next = stream->free_frames; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1126 stream->free_frames = frame; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1127 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
1128 stream->queued--; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1129 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1130 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1131 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1132 static ngx_inline void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1133 ngx_http_spdy_handle_stream(ngx_http_spdy_connection_t *sc, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1134 ngx_http_spdy_stream_t *stream) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1135 { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1136 ngx_event_t *wev; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1137 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1138 if (stream->handled || stream->blocked || stream->exhausted) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1139 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1140 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1141 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1142 wev = stream->request->connection->write; |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1143 |
5814
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1144 /* |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1145 * This timer can only be set if the stream was delayed because of rate |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1146 * limit. In that case the event should be triggered by the timer. |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1147 */ |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1148 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1149 if (!wev->timer_set) { |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1150 wev->delayed = 0; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1151 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1152 stream->handled = 1; |
5530
827e53c136b0
SPDY: use ngx_queue_t to queue streams for post processing.
Valentin Bartenev <vbart@nginx.com>
parents:
5529
diff
changeset
|
1153 ngx_queue_insert_tail(&sc->posted, &stream->queue); |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1154 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1155 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1156 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1157 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1158 static void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1159 ngx_http_spdy_filter_cleanup(void *data) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1160 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1161 ngx_http_spdy_stream_t *stream = data; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1162 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1163 size_t delta; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1164 ngx_http_spdy_out_frame_t *frame, **fn; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1165 ngx_http_spdy_connection_t *sc; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1166 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1167 if (stream->handled) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1168 stream->handled = 0; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1169 ngx_queue_remove(&stream->queue); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1170 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1171 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
1172 if (stream->queued == 0) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1173 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1174 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1175 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1176 delta = 0; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1177 sc = stream->connection; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1178 fn = &sc->last_out; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1179 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1180 for ( ;; ) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1181 frame = *fn; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1182 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1183 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1184 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1185 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1186 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1187 if (frame->stream == stream && !frame->blocked) { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1188 *fn = frame->next; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1189 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1190 delta += frame->length; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1191 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1192 if (--stream->queued == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1193 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1194 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1195 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1196 continue; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1197 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1198 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1199 fn = &frame->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1200 } |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1201 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1202 if (sc->send_window == 0 && delta && !ngx_queue_empty(&sc->waiting)) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1203 ngx_queue_add(&sc->posted, &sc->waiting); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1204 ngx_queue_init(&sc->waiting); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1205 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1206 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1207 sc->send_window += delta; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1208 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1209 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1210 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1211 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1212 ngx_http_spdy_filter_init(ngx_conf_t *cf) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1213 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1214 ngx_http_next_header_filter = ngx_http_top_header_filter; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1215 ngx_http_top_header_filter = ngx_http_spdy_header_filter; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1216 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1217 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1218 } |