Mercurial > hg > nginx-quic
annotate src/http/ngx_http_spdy_filter_module.c @ 5989:ec01b1d1fff1
Mail: client SSL certificates support.
The "ssl_verify_client", "ssl_verify_depth", "ssl_client_certificate",
"ssl_trusted_certificate", and "ssl_crl" directives introduced to control
SSL client certificate verification in mail proxy module.
If there is a certificate, detail of the certificate are passed to
the auth_http script configured via Auth-SSL-Verify, Auth-SSL-Subject,
Auth-SSL-Issuer, Auth-SSL-Serial, Auth-SSL-Fingerprint headers. If
the auth_http_pass_client_cert directive is set, client certificate
in PEM format will be passed in the Auth-SSL-Cert header (urlencoded).
If there is no required certificate provided during an SSL handshake
or certificate verification fails then a protocol-specific error is
returned after the SSL handshake and the connection is closed.
Based on previous work by Sven Peter, Franck Levionnois and Filipe Da Silva.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 25 Feb 2015 17:48:05 +0300 |
parents | 87ada3ba1392 |
children |
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 |
5891
87ada3ba1392
SPDY: stop emitting multiple empty header values.
Piotr Sikora <piotr@cloudflare.com>
parents:
5814
diff
changeset
|
496 if (h[j].value.len) { |
87ada3ba1392
SPDY: stop emitting multiple empty header values.
Piotr Sikora <piotr@cloudflare.com>
parents:
5814
diff
changeset
|
497 if (last != p) { |
87ada3ba1392
SPDY: stop emitting multiple empty header values.
Piotr Sikora <piotr@cloudflare.com>
parents:
5814
diff
changeset
|
498 *last++ = '\0'; |
87ada3ba1392
SPDY: stop emitting multiple empty header values.
Piotr Sikora <piotr@cloudflare.com>
parents:
5814
diff
changeset
|
499 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
500 |
5891
87ada3ba1392
SPDY: stop emitting multiple empty header values.
Piotr Sikora <piotr@cloudflare.com>
parents:
5814
diff
changeset
|
501 last = ngx_cpymem(last, h[j].value.data, h[j].value.len); |
87ada3ba1392
SPDY: stop emitting multiple empty header values.
Piotr Sikora <piotr@cloudflare.com>
parents:
5814
diff
changeset
|
502 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
503 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
504 h[j].hash = 2; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
507 (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
|
508 last - p); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
509 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
510 count++; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
511 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
512 |
5242
5776804fff04
SPDY: use proper macros for value length and headers counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5121
diff
changeset
|
513 (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
|
514 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
515 stream = r->spdy_stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
516 sc = stream->connection; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
517 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
518 len = last - buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
519 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
520 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
|
521 + NGX_SPDY_SYN_REPLY_SIZE |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
522 + deflateBound(&sc->zstream_out, len)); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
523 if (b == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
524 ngx_free(buf); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
525 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
526 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
527 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
528 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
|
529 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
530 sc->zstream_out.next_in = buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
531 sc->zstream_out.avail_in = len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
532 sc->zstream_out.next_out = b->last; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
533 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
|
534 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
535 rc = deflate(&sc->zstream_out, Z_SYNC_FLUSH); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
536 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
537 ngx_free(buf); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
538 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
539 if (rc != Z_OK) { |
5693
701d6e17e42c
SPDY: improved logging.
Valentin Bartenev <vbart@nginx.com>
parents:
5644
diff
changeset
|
540 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "deflate() failed: %d", rc); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
541 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
542 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
543 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
544 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
|
545 "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
|
546 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
|
547 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
|
548 rc); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
549 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
550 b->last = sc->zstream_out.next_out; |
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 p = b->pos; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
553 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
|
554 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
555 len = b->last - b->pos; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
556 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
557 r->header_size = len; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
558 |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
559 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
|
560 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
561 if (r->header_only) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
562 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
|
563 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
|
564 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
565 } else { |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
566 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
|
567 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
568 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
569 (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
|
570 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
571 cl = ngx_alloc_chain_link(r->pool); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
572 if (cl == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
573 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
574 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
575 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
576 cl->buf = b; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
577 cl->next = NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
578 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
579 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
|
580 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
581 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
582 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
583 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
584 frame->first = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
585 frame->last = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
586 frame->handler = ngx_http_spdy_syn_frame_handler; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
587 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
|
588 frame->length = len; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
589 frame->priority = stream->priority; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
590 frame->blocked = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
591 frame->fin = r->header_only; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
592 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
593 ngx_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
|
594 "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
|
595 stream->id, frame, frame->length); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
596 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
597 ngx_http_spdy_queue_blocked_frame(sc, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
598 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
599 cln = ngx_http_cleanup_add(r, 0); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
600 if (cln == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
601 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
602 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
603 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
604 cln->handler = ngx_http_spdy_filter_cleanup; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
605 cln->data = stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
606 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
607 stream->queued = 1; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
608 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
609 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
|
610 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
|
611 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
612 return ngx_http_spdy_filter_send(c, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
613 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
614 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
615 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
616 static ngx_chain_t * |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
617 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
|
618 { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
619 off_t size, offset; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
620 size_t rest, frame_size; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
621 ngx_chain_t *cl, *out, **ln; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
622 ngx_http_request_t *r; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
623 ngx_http_spdy_stream_t *stream; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
624 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
|
625 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
|
626 ngx_http_spdy_connection_t *sc; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
627 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
628 r = fc->data; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
629 stream = r->spdy_stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
630 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
631 #if (NGX_SUPPRESS_WARN) |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
632 size = 0; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
633 #endif |
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 while (in) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
636 size = ngx_buf_size(in->buf); |
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 if (size || in->buf->last_buf) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
639 break; |
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 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
642 in = in->next; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
643 } |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
644 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
645 if (in == NULL) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
646 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
647 if (stream->queued) { |
5512
9fffc0c46e5c
SPDY: fixed possible premature close of stream.
Valentin Bartenev <vbart@nginx.com>
parents:
5511
diff
changeset
|
648 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
|
649 } else { |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
650 fc->buffered &= ~NGX_SPDY_BUFFERED; |
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 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
653 return NULL; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
654 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
655 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
656 sc = stream->connection; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
657 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
658 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
|
659 fc->write->delayed = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
660 return in; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
661 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
662 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
663 if (limit == 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
|
664 limit = sc->send_window; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
665 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
666 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
667 if (limit > stream->send_window) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
668 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
|
669 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
670 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
671 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
|
672 cl = ngx_alloc_chain_link(r->pool); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
673 if (cl == NULL) { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
674 return NGX_CHAIN_ERROR; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
675 } |
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 cl->buf = in->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
678 in->buf = cl->buf->shadow; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
679 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
680 offset = ngx_buf_in_memory(in->buf) |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
681 ? (cl->buf->pos - in->buf->pos) |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
682 : (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
|
683 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
684 cl->next = stream->free_bufs; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
685 stream->free_bufs = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
686 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
687 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
688 offset = 0; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
689 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
690 |
5516
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
691 #if (NGX_SUPPRESS_WARN) |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
692 cl = NULL; |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
693 #endif |
439d05a037a3
SPDY: fixed build, broken by b7ee1bae0ffa.
Valentin Bartenev <vbart@nginx.com>
parents:
5515
diff
changeset
|
694 |
5515
e5fb14e85040
SPDY: added the "spdy_chunk_size" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
5514
diff
changeset
|
695 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
|
696 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
697 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
|
698 : slcf->chunk_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
699 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
700 for ( ;; ) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
701 ln = &out; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
702 rest = frame_size; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
703 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
704 while ((off_t) rest >= size) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
705 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
706 if (offset) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
707 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
|
708 offset, size); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
709 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
710 return NGX_CHAIN_ERROR; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
713 offset = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
714 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
715 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
716 cl = ngx_alloc_chain_link(r->pool); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
717 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
718 return NGX_CHAIN_ERROR; |
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 cl->buf = in->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
722 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
723 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
724 *ln = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
725 ln = &cl->next; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
726 |
5517
9d1479234f3c
SPDY: fixed off_t/size_t type conversions on 32 bits platforms.
Valentin Bartenev <vbart@nginx.com>
parents:
5516
diff
changeset
|
727 rest -= (size_t) size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
728 in = in->next; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
729 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
730 if (in == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
731 frame_size -= rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
732 rest = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
733 break; |
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 size = ngx_buf_size(in->buf); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
737 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
738 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
739 if (rest) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
740 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
|
741 offset, rest); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
742 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
743 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
744 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
745 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
746 cl->buf->flush = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
747 cl->buf->last_buf = 0; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
748 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
749 *ln = cl; |
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 offset += rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
752 size -= rest; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
753 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
754 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
755 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
|
756 out, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
757 if (frame == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
758 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
759 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
760 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
761 ngx_http_spdy_queue_frame(sc, frame); |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
762 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
763 sc->send_window -= frame_size; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
764 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
765 stream->send_window -= frame_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
766 stream->queued++; |
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 if (in == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
769 break; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
770 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
771 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
772 limit -= frame_size; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
773 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
774 if (limit == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
775 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
776 } |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
777 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
778 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
|
779 frame_size = (size_t) limit; |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
780 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
781 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
782 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
783 if (offset) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
784 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
|
785 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
786 return NGX_CHAIN_ERROR; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
787 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
788 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
789 in->buf = cl->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
790 ngx_free_chain(r->pool, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
791 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
792 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
793 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
|
794 return NGX_CHAIN_ERROR; |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
795 } |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
796 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
797 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
|
798 fc->write->delayed = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
799 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
800 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
801 return in; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
802 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
803 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
804 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
805 static ngx_chain_t * |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
806 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
|
807 off_t offset, off_t size) |
5514
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 ngx_buf_t *chunk; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
810 ngx_chain_t *cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
811 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
812 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
|
813 if (cl == NULL) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
814 return NULL; |
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 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
817 chunk = cl->buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
818 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
819 ngx_memcpy(chunk, buf, sizeof(ngx_buf_t)); |
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 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
|
822 chunk->shadow = buf; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
823 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
824 if (ngx_buf_in_memory(chunk)) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
825 chunk->pos += offset; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
826 chunk->last = chunk->pos + size; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
827 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
828 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
829 if (chunk->in_file) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
830 chunk->file_pos += offset; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
831 chunk->file_last = chunk->file_pos + size; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
832 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
833 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
834 return cl; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
835 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
836 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
837 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
838 static ngx_http_spdy_out_frame_t * |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
839 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
|
840 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
|
841 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
842 u_char *p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
843 ngx_buf_t *buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
844 ngx_uint_t flags; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
845 ngx_chain_t *cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
846 ngx_http_spdy_out_frame_t *frame; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
849 frame = stream->free_frames; |
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 if (frame) { |
5528
d5de6c25b759
SPDY: use frame->next pointer to chain free frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5517
diff
changeset
|
852 stream->free_frames = frame->next; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
853 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
854 } else { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
855 frame = ngx_palloc(stream->request->pool, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
856 sizeof(ngx_http_spdy_out_frame_t)); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
857 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
858 return NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
859 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
860 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
861 |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
862 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
|
863 |
5495
97f6cd787766
SPDY: a bit smarter ngx_http_spdy_filter_get_data_frame().
Valentin Bartenev <vbart@nginx.com>
parents:
5494
diff
changeset
|
864 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
|
865 "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
|
866 stream->id, frame, len, flags); |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
867 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
868 cl = ngx_chain_get_free_buf(stream->request->pool, |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
869 &stream->free_data_headers); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
870 if (cl == NULL) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
871 return NULL; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
872 } |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
873 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
874 buf = cl->buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
875 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
876 if (buf->start) { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
877 p = buf->start; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
878 buf->pos = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
879 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
880 p += NGX_SPDY_SID_SIZE; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
881 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
882 (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
|
883 |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
884 } else { |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
885 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
|
886 if (p == NULL) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
887 return NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
888 } |
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 buf->pos = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
891 buf->start = p; |
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 p = ngx_spdy_frame_write_sid(p, stream->id); |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
894 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
|
895 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
896 buf->last = p; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
897 buf->end = p; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
898 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
899 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
|
900 buf->memory = 1; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
901 } |
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 cl->next = first; |
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
904 first = cl; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
905 |
5644
b948f9c73111
SPDY: avoid creating flush frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5576
diff
changeset
|
906 last->buf->flush = 1; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
907 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
908 frame->first = first; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
909 frame->last = last; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
910 frame->handler = ngx_http_spdy_data_frame_handler; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
911 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
|
912 frame->length = len; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
913 frame->priority = stream->priority; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
914 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
|
915 frame->fin = last->buf->last_buf; |
5121
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 return frame; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
918 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
919 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
920 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
921 static ngx_inline ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
922 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
|
923 { |
5493
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
924 stream->blocked = 1; |
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
925 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
926 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
|
927 fc->error = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
928 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
929 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
930 |
5493
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
931 stream->blocked = 0; |
916cb6d28f6a
SPDY: fixed possible request hang.
Valentin Bartenev <vbart@nginx.com>
parents:
5483
diff
changeset
|
932 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
933 if (stream->queued) { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
934 fc->buffered |= NGX_SPDY_BUFFERED; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
935 fc->write->delayed = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
936 return NGX_AGAIN; |
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 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
939 fc->buffered &= ~NGX_SPDY_BUFFERED; |
5121
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 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
942 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
943 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
944 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
945 static ngx_inline ngx_int_t |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
946 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
|
947 ngx_http_spdy_stream_t *stream) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
948 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
949 if (stream->send_window <= 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
950 stream->exhausted = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
951 return NGX_DECLINED; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
952 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
953 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
954 if (sc->send_window == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
955 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
|
956 return NGX_DECLINED; |
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 return NGX_OK; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
960 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
961 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
962 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
963 static void |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
964 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
|
965 ngx_http_spdy_stream_t *stream) |
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 ngx_queue_t *q; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
968 ngx_http_spdy_stream_t *s; |
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 if (stream->handled) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
971 return; |
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 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
974 stream->handled = 1; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
975 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
976 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
|
977 q != ngx_queue_sentinel(&sc->waiting); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
978 q = ngx_queue_prev(q)) |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
979 { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
980 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
|
981 |
5576
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
982 /* |
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
983 * 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
|
984 */ |
2bc609a4b516
SPDY: fixed reversed priority order in window waiting queue.
Valentin Bartenev <vbart@nginx.com>
parents:
5549
diff
changeset
|
985 if (stream->priority >= s->priority) { |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
986 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
987 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
988 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
989 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
990 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
|
991 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
992 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
993 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
994 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
995 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
|
996 ngx_http_spdy_out_frame_t *frame) |
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 ngx_buf_t *buf; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
999 ngx_http_spdy_stream_t *stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1000 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1001 buf = frame->first->buf; |
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 if (buf->pos != buf->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1004 return NGX_AGAIN; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1007 stream = frame->stream; |
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_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
|
1010 "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
|
1011 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1012 ngx_free_chain(stream->request->pool, frame->first); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1013 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1014 ngx_http_spdy_handle_frame(stream, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1015 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1016 ngx_http_spdy_handle_stream(sc, stream); |
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 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1019 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1020 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1021 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1022 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1023 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
|
1024 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1025 { |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1026 ngx_buf_t *buf; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1027 ngx_chain_t *cl, *ln; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1028 ngx_http_spdy_stream_t *stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1029 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1030 stream = frame->stream; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1031 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1032 cl = frame->first; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1033 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1034 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
|
1035 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1036 if (cl->buf->pos != cl->buf->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1037 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
|
1038 "spdy:%ui DATA frame %p was sent partially", |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1039 stream->id, frame); |
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 return NGX_AGAIN; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1044 ln = cl->next; |
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 cl->next = stream->free_data_headers; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1047 stream->free_data_headers = cl; |
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 if (cl == frame->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1050 goto done; |
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 cl = ln; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1054 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1055 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1056 for ( ;; ) { |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1057 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
|
1058 buf = cl->buf->shadow; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1059 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1060 if (ngx_buf_in_memory(buf)) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1061 buf->pos = cl->buf->pos; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1062 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1063 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1064 if (buf->in_file) { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1065 buf->file_pos = cl->buf->file_pos; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1066 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1067 } |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1068 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1069 if (ngx_buf_size(cl->buf) != 0) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1070 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1071 if (cl != frame->first) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1072 frame->first = cl; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1073 ngx_http_spdy_handle_stream(sc, stream); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1074 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1075 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1076 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
|
1077 "spdy:%ui DATA frame %p was sent partially", |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1078 stream->id, frame); |
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 return NGX_AGAIN; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1081 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1082 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1083 ln = cl->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1084 |
5514
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1085 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
|
1086 cl->next = stream->free_bufs; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1087 stream->free_bufs = cl; |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1088 |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1089 } else { |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1090 ngx_free_chain(stream->request->pool, cl); |
b7ee1bae0ffa
SPDY: implemented buffers chain splitting.
Valentin Bartenev <vbart@nginx.com>
parents:
5513
diff
changeset
|
1091 } |
5121
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 if (cl == frame->last) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1094 goto done; |
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 cl = ln; |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1100 done: |
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 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
|
1103 "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
|
1104 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1105 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
|
1106 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1107 ngx_http_spdy_handle_frame(stream, frame); |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1108 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1109 ngx_http_spdy_handle_stream(sc, stream); |
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 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1112 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1113 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1114 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1115 static ngx_inline void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1116 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
|
1117 ngx_http_spdy_out_frame_t *frame) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1118 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1119 ngx_http_request_t *r; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1120 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1121 r = stream->request; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1122 |
5529
e4adaa47af65
SPDY: store the length of frame instead of its whole size.
Valentin Bartenev <vbart@nginx.com>
parents:
5528
diff
changeset
|
1123 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
|
1124 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1125 if (frame->fin) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1126 stream->out_closed = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1127 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1128 |
5528
d5de6c25b759
SPDY: use frame->next pointer to chain free frames.
Valentin Bartenev <vbart@nginx.com>
parents:
5517
diff
changeset
|
1129 frame->next = stream->free_frames; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1130 stream->free_frames = frame; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1131 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
1132 stream->queued--; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1133 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1134 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1135 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1136 static ngx_inline void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1137 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
|
1138 ngx_http_spdy_stream_t *stream) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1139 { |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1140 ngx_event_t *wev; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1141 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1142 if (stream->handled || stream->blocked || stream->exhausted) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1143 return; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1144 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1145 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1146 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
|
1147 |
5814
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1148 /* |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1149 * This timer can only be set if the stream was delayed because of rate |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1150 * limit. In that case the event should be triggered by the timer. |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1151 */ |
a5886df87cbb
SPDY: added a comment about handling stream with the timer set.
Valentin Bartenev <vbart@nginx.com>
parents:
5693
diff
changeset
|
1152 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1153 if (!wev->timer_set) { |
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1154 wev->delayed = 0; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1155 |
5513
311803b21504
SPDY: body filter was replaced by c->send_chain() function.
Valentin Bartenev <vbart@nginx.com>
parents:
5512
diff
changeset
|
1156 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
|
1157 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
|
1158 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1159 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1160 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1161 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1162 static void |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1163 ngx_http_spdy_filter_cleanup(void *data) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1164 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1165 ngx_http_spdy_stream_t *stream = data; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1166 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1167 size_t delta; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1168 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
|
1169 ngx_http_spdy_connection_t *sc; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1170 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1171 if (stream->handled) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1172 stream->handled = 0; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1173 ngx_queue_remove(&stream->queue); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1174 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1175 |
5508
9053fdcea4b7
SPDY: better name for queued frames counter.
Valentin Bartenev <vbart@nginx.com>
parents:
5495
diff
changeset
|
1176 if (stream->queued == 0) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1177 return; |
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 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1180 delta = 0; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1181 sc = stream->connection; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1182 fn = &sc->last_out; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1183 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1184 for ( ;; ) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1185 frame = *fn; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1186 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1187 if (frame == NULL) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1188 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1189 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1190 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1191 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
|
1192 *fn = frame->next; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1193 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1194 delta += frame->length; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1195 |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1196 if (--stream->queued == 0) { |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1197 break; |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1198 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1199 |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1200 continue; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1201 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1202 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1203 fn = &frame->next; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1204 } |
5549
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1205 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1206 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
|
1207 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
|
1208 ngx_queue_init(&sc->waiting); |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1209 } |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1210 |
39d7eef2e332
SPDY: protocol implementation switched to spdy/3.1.
Valentin Bartenev <vbart@nginx.com>
parents:
5530
diff
changeset
|
1211 sc->send_window += delta; |
5121
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1214 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1215 static ngx_int_t |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1216 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
|
1217 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1218 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
|
1219 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
|
1220 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1221 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1222 } |