comparison src/http/ngx_http_request.c @ 6246:257b51c37c5a

The HTTP/2 implementation (RFC 7240, 7241). The SPDY support is removed, as it's incompatible with the new module.
author Valentin Bartenev <vbart@nginx.com>
date Fri, 11 Sep 2015 20:13:06 +0300
parents 06e850859a26
children 909b5b191f25
comparison
equal deleted inserted replaced
6245:3cf25d33886a 6246:257b51c37c5a
310 310
311 rev = c->read; 311 rev = c->read;
312 rev->handler = ngx_http_wait_request_handler; 312 rev->handler = ngx_http_wait_request_handler;
313 c->write->handler = ngx_http_empty_handler; 313 c->write->handler = ngx_http_empty_handler;
314 314
315 #if (NGX_HTTP_SPDY) 315 #if (NGX_HTTP_V2)
316 if (hc->addr_conf->spdy) { 316 if (hc->addr_conf->http2) {
317 rev->handler = ngx_http_spdy_init; 317 rev->handler = ngx_http_v2_init;
318 } 318 }
319 #endif 319 #endif
320 320
321 #if (NGX_HTTP_SSL) 321 #if (NGX_HTTP_SSL)
322 { 322 {
762 * Opera and recent Mozilla send the alert. 762 * Opera and recent Mozilla send the alert.
763 */ 763 */
764 764
765 c->ssl->no_wait_shutdown = 1; 765 c->ssl->no_wait_shutdown = 1;
766 766
767 #if (NGX_HTTP_SPDY \ 767 #if (NGX_HTTP_V2 \
768 && (defined TLSEXT_TYPE_application_layer_protocol_negotiation \ 768 && (defined TLSEXT_TYPE_application_layer_protocol_negotiation \
769 || defined TLSEXT_TYPE_next_proto_neg)) 769 || defined TLSEXT_TYPE_next_proto_neg))
770 { 770 {
771 unsigned int len; 771 unsigned int len;
772 const unsigned char *data; 772 const unsigned char *data;
773 static const ngx_str_t spdy = ngx_string(NGX_SPDY_NPN_NEGOTIATED);
774 773
775 #ifdef TLSEXT_TYPE_application_layer_protocol_negotiation 774 #ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
776 SSL_get0_alpn_selected(c->ssl->connection, &data, &len); 775 SSL_get0_alpn_selected(c->ssl->connection, &data, &len);
777 776
778 #ifdef TLSEXT_TYPE_next_proto_neg 777 #ifdef TLSEXT_TYPE_next_proto_neg
783 782
784 #else /* TLSEXT_TYPE_next_proto_neg */ 783 #else /* TLSEXT_TYPE_next_proto_neg */
785 SSL_get0_next_proto_negotiated(c->ssl->connection, &data, &len); 784 SSL_get0_next_proto_negotiated(c->ssl->connection, &data, &len);
786 #endif 785 #endif
787 786
788 if (len == spdy.len && ngx_strncmp(data, spdy.data, spdy.len) == 0) { 787 if (len == 2 && data[0] == 'h' && data[1] == '2') {
789 ngx_http_spdy_init(c->read); 788 ngx_http_v2_init(c->read);
790 return; 789 return;
791 } 790 }
792 } 791 }
793 #endif 792 #endif
794 793
2497 static void 2496 static void
2498 ngx_http_finalize_connection(ngx_http_request_t *r) 2497 ngx_http_finalize_connection(ngx_http_request_t *r)
2499 { 2498 {
2500 ngx_http_core_loc_conf_t *clcf; 2499 ngx_http_core_loc_conf_t *clcf;
2501 2500
2502 #if (NGX_HTTP_SPDY) 2501 #if (NGX_HTTP_V2)
2503 if (r->spdy_stream) { 2502 if (r->stream) {
2504 ngx_http_close_request(r, 0); 2503 ngx_http_close_request(r, 0);
2505 return; 2504 return;
2506 } 2505 }
2507 #endif 2506 #endif
2508 2507
2563 r->read_event_handler = r->discard_body ? 2562 r->read_event_handler = r->discard_body ?
2564 ngx_http_discarded_request_body_handler: 2563 ngx_http_discarded_request_body_handler:
2565 ngx_http_test_reading; 2564 ngx_http_test_reading;
2566 r->write_event_handler = ngx_http_writer; 2565 r->write_event_handler = ngx_http_writer;
2567 2566
2568 #if (NGX_HTTP_SPDY) 2567 #if (NGX_HTTP_V2)
2569 if (r->spdy_stream) { 2568 if (r->stream) {
2570 return NGX_OK; 2569 return NGX_OK;
2571 } 2570 }
2572 #endif 2571 #endif
2573 2572
2574 wev = r->connection->write; 2573 wev = r->connection->write;
2654 return; 2653 return;
2655 } 2654 }
2656 2655
2657 if (r->buffered || r->postponed || (r == r->main && c->buffered)) { 2656 if (r->buffered || r->postponed || (r == r->main && c->buffered)) {
2658 2657
2659 #if (NGX_HTTP_SPDY) 2658 #if (NGX_HTTP_V2)
2660 if (r->spdy_stream) { 2659 if (r->stream) {
2661 return; 2660 return;
2662 } 2661 }
2663 #endif 2662 #endif
2664 2663
2665 if (!wev->delayed) { 2664 if (!wev->delayed) {
2722 c = r->connection; 2721 c = r->connection;
2723 rev = c->read; 2722 rev = c->read;
2724 2723
2725 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http test reading"); 2724 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http test reading");
2726 2725
2727 #if (NGX_HTTP_SPDY) 2726 #if (NGX_HTTP_V2)
2728 2727
2729 if (r->spdy_stream) { 2728 if (r->stream) {
2730 if (c->error) { 2729 if (c->error) {
2731 err = 0; 2730 err = 0;
2732 goto closed; 2731 goto closed;
2733 } 2732 }
2734 2733
3397 3396
3398 if (r->count || r->blocked) { 3397 if (r->count || r->blocked) {
3399 return; 3398 return;
3400 } 3399 }
3401 3400
3402 #if (NGX_HTTP_SPDY) 3401 #if (NGX_HTTP_V2)
3403 if (r->spdy_stream) { 3402 if (r->stream) {
3404 ngx_http_spdy_close_stream(r->spdy_stream, rc); 3403 ngx_http_v2_close_stream(r->stream, rc);
3405 return; 3404 return;
3406 } 3405 }
3407 #endif 3406 #endif
3408 3407
3409 ngx_http_free_request(r, rc); 3408 ngx_http_free_request(r, rc);