Mercurial > hg > nginx-quic
annotate src/http/ngx_http_spdy_filter_module.c @ 5686:5cf537731218
SPDY: fixed one case of improper memory allocation error handling.
Now ngx_http_spdy_construct_request_line() doesn't try to finalize request
in case of failed memory allocation.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 30 Apr 2014 02:16:21 +0400 |
parents | b948f9c73111 |
children | 701d6e17e42c |
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) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
536 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
537 "spdy deflate() failed: %d", rc); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
538 return NGX_ERROR; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
541 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
|
542 "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
|
543 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
|
544 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
|
545 rc); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
546 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
547 b->last = sc->zstream_out.next_out; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
548 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
549 p = b->pos; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
550 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
|
551 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
552 len = b->last - b->pos; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
553 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
554 r->header_size = len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
555 |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
556 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
|
557 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
558 if (r->header_only) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
559 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
|
560 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
|
561 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
562 } else { |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
563 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
|
564 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
565 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
566 (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
|
567 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
568 cl = ngx_alloc_chain_link(r->pool); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
569 if (cl == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
570 return NGX_ERROR; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
573 cl->buf = b; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
574 cl->next = NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
575 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
576 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
|
577 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
578 return NGX_ERROR; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
581 frame->first = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
582 frame->last = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
583 frame->handler = ngx_http_spdy_syn_frame_handler; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
584 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
|
585 frame->length = len; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
586 frame->priority = stream->priority; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
587 frame->blocked = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
588 frame->fin = r->header_only; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
589 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
590 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
|
591 "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
|
592 stream->id, frame, frame->length); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
593 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
594 ngx_http_spdy_queue_blocked_frame(sc, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
595 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
596 cln = ngx_http_cleanup_add(r, 0); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
597 if (cln == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
598 return NGX_ERROR; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
601 cln->handler = ngx_http_spdy_filter_cleanup; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
602 cln->data = stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
603 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
604 stream->queued = 1; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
605 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
606 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
|
607 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
|
608 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
609 return ngx_http_spdy_filter_send(c, stream); |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
612 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
613 static ngx_chain_t * |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
614 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
|
615 { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
616 off_t size, offset; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
617 size_t rest, frame_size; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
618 ngx_chain_t *cl, *out, **ln; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
619 ngx_http_request_t *r; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
620 ngx_http_spdy_stream_t *stream; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
621 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
|
622 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
|
623 ngx_http_spdy_connection_t *sc; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
624 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
625 r = fc->data; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
626 stream = r->spdy_stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
627 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
628 #if (NGX_SUPPRESS_WARN) |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
629 size = 0; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
630 #endif |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
631 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
632 while (in) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
633 size = ngx_buf_size(in->buf); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
634 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
635 if (size || in->buf->last_buf) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
636 break; |
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 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
639 in = in->next; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
640 } |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
641 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
642 if (in == NULL) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
643 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
644 if (stream->queued) { |
5512
9fffc0c46e5c
SPDY: fixed possible premature close of stream.
Valentin Bartenev <vbart@nginx.com>
parents:
5511
diff
changeset
|
645 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
|
646 } else { |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
647 fc->buffered &= ~NGX_SPDY_BUFFERED; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
648 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
649 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
650 return NULL; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
651 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
652 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
653 sc = stream->connection; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
654 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
655 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
|
656 fc->write->delayed = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
657 return in; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
660 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
|
661 limit = sc->send_window; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
664 if (limit > stream->send_window) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
665 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
|
666 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
667 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
668 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
|
669 cl = ngx_alloc_chain_link(r->pool); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
670 if (cl == NULL) { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
671 return NGX_CHAIN_ERROR; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
672 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
673 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
674 cl->buf = in->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
675 in->buf = cl->buf->shadow; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
676 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
677 offset = ngx_buf_in_memory(in->buf) |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
678 ? (cl->buf->pos - in->buf->pos) |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
679 : (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
|
680 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
681 cl->next = stream->free_bufs; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
682 stream->free_bufs = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
683 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
684 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
685 offset = 0; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
686 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
687 |
5516
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
688 #if (NGX_SUPPRESS_WARN) |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
689 cl = NULL; |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
690 #endif |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
691 |
5515
e5fb14e85040
SPDY: added the "spdy_chunk_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
5514
diff
changeset
|
692 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
|
693 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
694 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
|
695 : slcf->chunk_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
696 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
697 for ( ;; ) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
698 ln = &out; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
699 rest = frame_size; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
700 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
701 while ((off_t) rest >= size) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
702 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
703 if (offset) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
704 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
|
705 offset, size); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
706 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
707 return NGX_CHAIN_ERROR; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
710 offset = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
711 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
712 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
713 cl = ngx_alloc_chain_link(r->pool); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
714 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
715 return NGX_CHAIN_ERROR; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
718 cl->buf = in->buf; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
721 *ln = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
722 ln = &cl->next; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
723 |
5517
9d1479234f3c
SPDY: fixed off_t/size_t type conversions on 32 bits platforms.
Valentin Bartenev <vbart@nginx.com>
parents:
5516
diff
changeset
|
724 rest -= (size_t) size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
725 in = in->next; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
726 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
727 if (in == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
728 frame_size -= rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
729 rest = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
730 break; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
733 size = ngx_buf_size(in->buf); |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
736 if (rest) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
737 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
|
738 offset, rest); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
739 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
740 return NGX_CHAIN_ERROR; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
743 cl->buf->flush = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
744 cl->buf->last_buf = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
745 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
746 *ln = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
747 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
748 offset += rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
749 size -= rest; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
752 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
|
753 out, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
754 if (frame == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
755 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
756 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
757 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
758 ngx_http_spdy_queue_frame(sc, frame); |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
759 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
760 sc->send_window -= frame_size; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
761 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
762 stream->send_window -= frame_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
763 stream->queued++; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
764 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
765 if (in == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
766 break; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
767 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
768 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
769 limit -= frame_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
770 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
771 if (limit == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
772 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
773 } |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
774 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
775 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
|
776 frame_size = (size_t) limit; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
777 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
778 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
779 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
780 if (offset) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
781 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
|
782 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
783 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
784 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
785 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
786 in->buf = cl->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
787 ngx_free_chain(r->pool, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
788 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
789 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
790 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
|
791 return NGX_CHAIN_ERROR; |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
792 } |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
793 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
794 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
|
795 fc->write->delayed = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
796 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
797 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
798 return in; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
802 static ngx_chain_t * |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
803 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
|
804 off_t offset, off_t size) |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
805 { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
806 ngx_buf_t *chunk; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
807 ngx_chain_t *cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
808 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
809 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
|
810 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
811 return NULL; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
814 chunk = cl->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
815 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
816 ngx_memcpy(chunk, buf, sizeof(ngx_buf_t)); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
817 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
818 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
|
819 chunk->shadow = buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
820 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
821 if (ngx_buf_in_memory(chunk)) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
822 chunk->pos += offset; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
823 chunk->last = chunk->pos + size; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
826 if (chunk->in_file) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
827 chunk->file_pos += offset; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
828 chunk->file_last = chunk->file_pos + size; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
831 return cl; |
5121
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
835 static ngx_http_spdy_out_frame_t * |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
836 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
|
837 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
|
838 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
839 u_char *p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
840 ngx_buf_t *buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
841 ngx_uint_t flags; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
842 ngx_chain_t *cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
843 ngx_http_spdy_out_frame_t *frame; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
846 frame = stream->free_frames; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
847 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
848 if (frame) { |
5528
d5de6c25b759
SPDY: use frame->next pointer to chain free frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5517
diff
changeset
|
849 stream->free_frames = frame->next; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
850 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
851 } else { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
852 frame = ngx_palloc(stream->request->pool, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
853 sizeof(ngx_http_spdy_out_frame_t)); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
854 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
855 return NULL; |
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 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
858 |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
859 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
|
860 |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
861 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
|
862 "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
|
863 stream->id, frame, len, flags); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
864 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
865 cl = ngx_chain_get_free_buf(stream->request->pool, |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
866 &stream->free_data_headers); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
867 if (cl == NULL) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
868 return NULL; |
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 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
871 buf = cl->buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
872 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
873 if (buf->start) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
874 p = buf->start; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
875 buf->pos = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
876 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
877 p += NGX_SPDY_SID_SIZE; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
878 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
879 (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
|
880 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
881 } else { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
882 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
|
883 if (p == NULL) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
884 return NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
885 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
886 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
887 buf->pos = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
888 buf->start = p; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
889 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
890 p = ngx_spdy_frame_write_sid(p, stream->id); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
891 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
|
892 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
893 buf->last = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
894 buf->end = p; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
895 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
896 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
|
897 buf->memory = 1; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
898 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
899 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
900 cl->next = first; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
901 first = cl; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
902 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
903 last->buf->flush = 1; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
904 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
905 frame->first = first; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
906 frame->last = last; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
907 frame->handler = ngx_http_spdy_data_frame_handler; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
908 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
|
909 frame->length = len; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
910 frame->priority = stream->priority; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
911 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
|
912 frame->fin = last->buf->last_buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
913 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
914 return frame; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
918 static ngx_inline ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
919 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
|
920 { |
5493
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
921 stream->blocked = 1; |
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
922 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
923 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
|
924 fc->error = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
925 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
926 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
927 |
5493
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
928 stream->blocked = 0; |
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
929 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
930 if (stream->queued) { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
931 fc->buffered |= NGX_SPDY_BUFFERED; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
932 fc->write->delayed = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
933 return NGX_AGAIN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
934 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
935 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
936 fc->buffered &= ~NGX_SPDY_BUFFERED; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
937 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
938 return NGX_OK; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
941 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
942 static ngx_inline ngx_int_t |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
943 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
|
944 ngx_http_spdy_stream_t *stream) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
945 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
946 if (stream->send_window <= 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
947 stream->exhausted = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
948 return NGX_DECLINED; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
951 if (sc->send_window == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
952 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
|
953 return NGX_DECLINED; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
956 return NGX_OK; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
960 static void |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
961 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
|
962 ngx_http_spdy_stream_t *stream) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
963 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
964 ngx_queue_t *q; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
965 ngx_http_spdy_stream_t *s; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
966 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
967 if (stream->handled) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
968 return; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
971 stream->handled = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
972 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
973 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
|
974 q != ngx_queue_sentinel(&sc->waiting); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
975 q = ngx_queue_prev(q)) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
976 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
977 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
|
978 |
5576
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
979 /* |
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
980 * 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
|
981 */ |
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
982 if (stream->priority >= s->priority) { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
983 break; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
987 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
|
988 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
989 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
990 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
991 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
992 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
|
993 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
994 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
995 ngx_buf_t *buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
996 ngx_http_spdy_stream_t *stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
997 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
998 buf = frame->first->buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
999 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1000 if (buf->pos != buf->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1001 return NGX_AGAIN; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1004 stream = frame->stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1005 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1006 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
|
1007 "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
|
1008 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1009 ngx_free_chain(stream->request->pool, frame->first); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1010 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1011 ngx_http_spdy_handle_frame(stream, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1012 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1013 ngx_http_spdy_handle_stream(sc, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1014 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1015 return NGX_OK; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1019 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1020 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
|
1021 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1022 { |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1023 ngx_buf_t *buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1024 ngx_chain_t *cl, *ln; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1025 ngx_http_spdy_stream_t *stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1026 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1027 stream = frame->stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1028 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1029 cl = frame->first; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1030 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1031 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
|
1032 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1033 if (cl->buf->pos != cl->buf->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1034 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
|
1035 "spdy:%ui DATA frame %p was sent partially", |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1036 stream->id, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1037 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1038 return NGX_AGAIN; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1041 ln = cl->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1042 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1043 cl->next = stream->free_data_headers; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1044 stream->free_data_headers = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1045 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1046 if (cl == frame->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1047 goto done; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1050 cl = ln; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1053 for ( ;; ) { |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1054 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
|
1055 buf = cl->buf->shadow; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1056 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1057 if (ngx_buf_in_memory(buf)) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1058 buf->pos = cl->buf->pos; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1061 if (buf->in_file) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1062 buf->file_pos = cl->buf->file_pos; |
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 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1065 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1066 if (ngx_buf_size(cl->buf) != 0) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1067 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1068 if (cl != frame->first) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1069 frame->first = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1070 ngx_http_spdy_handle_stream(sc, stream); |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1073 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
|
1074 "spdy:%ui DATA frame %p was sent partially", |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1075 stream->id, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1076 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1077 return NGX_AGAIN; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1080 ln = cl->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1081 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1082 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
|
1083 cl->next = stream->free_bufs; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1084 stream->free_bufs = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1085 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1086 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1087 ngx_free_chain(stream->request->pool, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1088 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1089 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1090 if (cl == frame->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1091 goto done; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1094 cl = ln; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1097 done: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1098 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1099 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
|
1100 "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
|
1101 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1102 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
|
1103 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1104 ngx_http_spdy_handle_frame(stream, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1105 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1106 ngx_http_spdy_handle_stream(sc, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1107 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1108 return NGX_OK; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1112 static ngx_inline void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1113 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
|
1114 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1115 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1116 ngx_http_request_t *r; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1117 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1118 r = stream->request; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1119 |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
1120 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
|
1121 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1122 if (frame->fin) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1123 stream->out_closed = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1124 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1125 |
5528
d5de6c25b759
SPDY: use frame->next pointer to chain free frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5517
diff
changeset
|
1126 frame->next = stream->free_frames; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1127 stream->free_frames = frame; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1128 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
1129 stream->queued--; |
5121
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1133 static ngx_inline void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1134 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
|
1135 ngx_http_spdy_stream_t *stream) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1136 { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1137 ngx_event_t *wev; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1138 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1139 if (stream->handled || stream->blocked || stream->exhausted) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1140 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1141 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1142 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1143 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
|
1144 |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1145 if (!wev->timer_set) { |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1146 wev->delayed = 0; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1147 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1148 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
|
1149 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
|
1150 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1151 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1152 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1153 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1154 static void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1155 ngx_http_spdy_filter_cleanup(void *data) |
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 ngx_http_spdy_stream_t *stream = data; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1158 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1159 size_t delta; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1160 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
|
1161 ngx_http_spdy_connection_t *sc; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1162 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1163 if (stream->handled) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1164 stream->handled = 0; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1165 ngx_queue_remove(&stream->queue); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1166 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1167 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
1168 if (stream->queued == 0) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1169 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1170 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1171 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1172 delta = 0; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1173 sc = stream->connection; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1174 fn = &sc->last_out; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1175 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1176 for ( ;; ) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1177 frame = *fn; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1178 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1179 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1180 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1181 } |
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->stream == stream && !frame->blocked) { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1184 *fn = frame->next; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1185 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1186 delta += frame->length; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1187 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1188 if (--stream->queued == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1189 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1190 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1191 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1192 continue; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1193 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1194 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1195 fn = &frame->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1196 } |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1197 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1198 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
|
1199 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
|
1200 ngx_queue_init(&sc->waiting); |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1203 sc->send_window += delta; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1204 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1205 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1206 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1207 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1208 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
|
1209 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1210 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
|
1211 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
|
1212 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1213 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1214 } |