Mercurial > hg > nginx
comparison src/http/ngx_http_header_filter_module.c @ 8238:a3257a725b3d quic
Fixed header creation for header_only responses in HTTP/3.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 19 Mar 2020 15:03:09 +0300 |
parents | 38c0898b6df7 |
children | 1efee5e4194c |
comparison
equal
deleted
inserted
replaced
8237:ff540f13d95d | 8238:a3257a725b3d |
---|---|
177 | 177 |
178 if (r != r->main) { | 178 if (r != r->main) { |
179 return NGX_OK; | 179 return NGX_OK; |
180 } | 180 } |
181 | 181 |
182 if (r->http_version < NGX_HTTP_VERSION_10) { | |
183 return NGX_OK; | |
184 } | |
185 | |
186 if (r->method == NGX_HTTP_HEAD) { | |
187 r->header_only = 1; | |
188 } | |
189 | |
190 if (r->headers_out.status_line.len == 0) { | |
191 if (r->headers_out.status == NGX_HTTP_NO_CONTENT | |
192 || r->headers_out.status == NGX_HTTP_NOT_MODIFIED) | |
193 { | |
194 r->header_only = 1; | |
195 } | |
196 } | |
197 | |
182 #if (NGX_HTTP_V3) | 198 #if (NGX_HTTP_V3) |
183 | 199 |
184 if (r->http_version == NGX_HTTP_VERSION_30) { | 200 if (r->http_version == NGX_HTTP_VERSION_30) { |
185 ngx_chain_t *cl; | 201 ngx_chain_t *cl; |
186 | 202 |
191 | 207 |
192 return ngx_http_write_filter(r, cl); | 208 return ngx_http_write_filter(r, cl); |
193 } | 209 } |
194 | 210 |
195 #endif | 211 #endif |
196 | |
197 if (r->http_version < NGX_HTTP_VERSION_10) { | |
198 return NGX_OK; | |
199 } | |
200 | |
201 if (r->method == NGX_HTTP_HEAD) { | |
202 r->header_only = 1; | |
203 } | |
204 | 212 |
205 if (r->headers_out.last_modified_time != -1) { | 213 if (r->headers_out.last_modified_time != -1) { |
206 if (r->headers_out.status != NGX_HTTP_OK | 214 if (r->headers_out.status != NGX_HTTP_OK |
207 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT | 215 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT |
208 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED) | 216 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED) |
233 && status < NGX_HTTP_LAST_2XX) | 241 && status < NGX_HTTP_LAST_2XX) |
234 { | 242 { |
235 /* 2XX */ | 243 /* 2XX */ |
236 | 244 |
237 if (status == NGX_HTTP_NO_CONTENT) { | 245 if (status == NGX_HTTP_NO_CONTENT) { |
238 r->header_only = 1; | |
239 ngx_str_null(&r->headers_out.content_type); | 246 ngx_str_null(&r->headers_out.content_type); |
240 r->headers_out.last_modified_time = -1; | 247 r->headers_out.last_modified_time = -1; |
241 r->headers_out.last_modified = NULL; | 248 r->headers_out.last_modified = NULL; |
242 r->headers_out.content_length = NULL; | 249 r->headers_out.content_length = NULL; |
243 r->headers_out.content_length_n = -1; | 250 r->headers_out.content_length_n = -1; |
249 | 256 |
250 } else if (status >= NGX_HTTP_MOVED_PERMANENTLY | 257 } else if (status >= NGX_HTTP_MOVED_PERMANENTLY |
251 && status < NGX_HTTP_LAST_3XX) | 258 && status < NGX_HTTP_LAST_3XX) |
252 { | 259 { |
253 /* 3XX */ | 260 /* 3XX */ |
254 | |
255 if (status == NGX_HTTP_NOT_MODIFIED) { | |
256 r->header_only = 1; | |
257 } | |
258 | 261 |
259 status = status - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_OFF_3XX; | 262 status = status - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_OFF_3XX; |
260 status_line = &ngx_http_status_lines[status]; | 263 status_line = &ngx_http_status_lines[status]; |
261 len += ngx_http_status_lines[status].len; | 264 len += ngx_http_status_lines[status].len; |
262 | 265 |