@@ -1,1211 +1,1300 @@
# HG changeset patch
# User Weibin Yao <yaoweibin@gmail.com>
# Date 1387716217 -28800
-# Sun Dec 22 20:43:37 2013 +0800
+# Sun Dec 22 20:43:37 2013 +0800
# Node ID 53a3d5ba3ad95f01ed917832080ba9620b66bdc7
-# Parent a297b7ad6f941cd8a179e36f6f2eba833b1257a5
+# Parent a297b7ad6f941cd8a179e36f6f2eba833b1257a5
Support SPDY v3
* Upgrade protocol from SPDY v2 to SPDY v3
* Flow control(upload and download)
* Switch option between SPDY v2 and v3
+
This patch were developed by Liangbing Li And Xiaochen Wang
+
diff -r a297b7ad6f94 -r 53a3d5ba3ad9 auto/sources
---- a/auto/sources Fri Dec 20 16:18:25 2013 +0400
-+++ b/auto/sources Sun Dec 22 20:43:37 2013 +0800
+--- a/auto/sources Fri Dec 20 16:18:25 2013 +0400
++++ b/auto/sources Sun Dec 22 20:43:37 2013 +0800
@@ -330,7 +330,8 @@
-src/http/ngx_http_spdy_module.h"
-HTTP_SPDY_SRCS="src/http/ngx_http_spdy.c \
-src/http/ngx_http_spdy_module.c \
-- src/http/ngx_http_spdy_filter_module.c"
-+ src/http/ngx_http_spdy_filter_module.c \
-+ src/http/ngx_http_spdy_v3.c"
-HTTP_CHARSET_FILTER_MODULE=ngx_http_charset_filter_module
+ src/http/ngx_http_spdy_module.h"
+ HTTP_SPDY_SRCS="src/http/ngx_http_spdy.c \
+ src/http/ngx_http_spdy_module.c \
+- src/http/ngx_http_spdy_filter_module.c"
++ src/http/ngx_http_spdy_filter_module.c \
++ src/http/ngx_http_spdy_v3.c"
+
+
+ HTTP_CHARSET_FILTER_MODULE=ngx_http_charset_filter_module
diff -r a297b7ad6f94 -r 53a3d5ba3ad9 src/http/modules/ngx_http_ssl_module.c
---- a/src/http/modules/ngx_http_ssl_module.c Fri Dec 20 16:18:25 2013 +0400
-+++ b/src/http/modules/ngx_http_ssl_module.c Sun Dec 22 20:43:37 2013 +0800
+--- a/src/http/modules/ngx_http_ssl_module.c Fri Dec 20 16:18:25 2013 +0400
++++ b/src/http/modules/ngx_http_ssl_module.c Sun Dec 22 20:43:37 2013 +0800
@@ -9,6 +9,9 @@
-#include <ngx_core.h>
-#include <ngx_http.h>
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+
+#if NGX_HTTP_SPDY
+#include <ngx_http_spdy_module.h>
+#endif
-typedef ngx_int_t (*ngx_ssl_variable_handler_pt)(ngx_connection_t *c,
-ngx_pool_t *pool, ngx_str_t *s);
+
+ typedef ngx_int_t (*ngx_ssl_variable_handler_pt)(ngx_connection_t *c,
+ ngx_pool_t *pool, ngx_str_t *s);
@@ -298,13 +301,20 @@
-#if (NGX_HTTP_SPDY)
-{
-- ngx_http_connection_t *hc;
-+ ngx_http_connection_t *hc;
-+ ngx_http_spdy_srv_conf_t *sscf;
-hc = c->data;
-+ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_spdy_module);
-if (hc->addr_conf->spdy) {
-- *out = (unsigned char *) NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
-- *outlen = sizeof(NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
-+ if (sscf->version == NGX_SPDY_VERSION_V3) {
-+ *out = (unsigned char *) NGX_SPDY_V3_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
-+ *outlen = sizeof(NGX_SPDY_V3_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
-+ } else {
-+ *out = (unsigned char *) NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
-+ *outlen = sizeof(NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
-+ }
-return SSL_TLSEXT_ERR_OK;
-}
+
+ #if (NGX_HTTP_SPDY)
+ {
+- ngx_http_connection_t *hc;
++ ngx_http_connection_t *hc;
++ ngx_http_spdy_srv_conf_t *sscf;
+
+ hc = c->data;
++ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_spdy_module);
+
+ if (hc->addr_conf->spdy) {
+- *out = (unsigned char *) NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
+- *outlen = sizeof(NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
++ if (sscf->version == NGX_SPDY_VERSION_V3) {
++ *out = (unsigned char *) NGX_SPDY_V3_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
++ *outlen = sizeof(NGX_SPDY_V3_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
++ } else {
++ *out = (unsigned char *) NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE;
++ *outlen = sizeof(NGX_SPDY_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE) - 1;
++ }
+
+ return SSL_TLSEXT_ERR_OK;
+ }
diff -r a297b7ad6f94 -r 53a3d5ba3ad9 src/http/ngx_http_request.c
---- a/src/http/ngx_http_request.c Fri Dec 20 16:18:25 2013 +0400
-+++ b/src/http/ngx_http_request.c Sun Dec 22 20:43:37 2013 +0800
+--- a/src/http/ngx_http_request.c Fri Dec 20 16:18:25 2013 +0400
++++ b/src/http/ngx_http_request.c Sun Dec 22 20:43:37 2013 +0800
@@ -9,6 +9,10 @@
-#include <ngx_core.h>
-#include <ngx_http.h>
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+
+#if (NGX_HTTP_SPDY && defined TLSEXT_TYPE_next_proto_neg)
+#include <ngx_http_spdy_module.h>
+#endif
+
-static void ngx_http_wait_request_handler(ngx_event_t *ev);
-static void ngx_http_process_request_line(ngx_event_t *rev);
+
+ static void ngx_http_wait_request_handler(ngx_event_t *ev);
+ static void ngx_http_process_request_line(ngx_event_t *rev);
@@ -730,9 +734,20 @@
-#if (NGX_HTTP_SPDY && defined TLSEXT_TYPE_next_proto_neg)
-{
-- unsigned int len;
-- const unsigned char *data;
-- static const ngx_str_t spdy = ngx_string(NGX_SPDY_NPN_NEGOTIATED);
-+ ngx_http_connection_t *hc;
-+ ngx_http_spdy_srv_conf_t *sscf;
-+ unsigned int len;
-+ const unsigned char *data;
-+ ngx_str_t spdy;
-+
-+ hc = c->data;
-+ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_spdy_module);
-+
-+ if (sscf->version == NGX_SPDY_VERSION_V3) {
-+ ngx_str_set(&spdy, NGX_SPDY_V3_NPN_NEGOTIATED);
-+ } else {
-+ ngx_str_set(&spdy, NGX_SPDY_NPN_NEGOTIATED);
-+ }
-SSL_get0_next_proto_negotiated(c->ssl->connection, &data, &len);
+
+ #if (NGX_HTTP_SPDY && defined TLSEXT_TYPE_next_proto_neg)
+ {
+- unsigned int len;
+- const unsigned char *data;
+- static const ngx_str_t spdy = ngx_string(NGX_SPDY_NPN_NEGOTIATED);
++ ngx_http_connection_t *hc;
++ ngx_http_spdy_srv_conf_t *sscf;
++ unsigned int len;
++ const unsigned char *data;
++ ngx_str_t spdy;
++
++ hc = c->data;
++ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_spdy_module);
++
++ if (sscf->version == NGX_SPDY_VERSION_V3) {
++ ngx_str_set(&spdy, NGX_SPDY_V3_NPN_NEGOTIATED);
++ } else {
++ ngx_str_set(&spdy, NGX_SPDY_NPN_NEGOTIATED);
++ }
+
+ SSL_get0_next_proto_negotiated(c->ssl->connection, &data, &len);
+
diff -r a297b7ad6f94 -r 53a3d5ba3ad9 src/http/ngx_http_spdy.c
---- a/src/http/ngx_http_spdy.c Fri Dec 20 16:18:25 2013 +0400
-+++ b/src/http/ngx_http_spdy.c Sun Dec 22 20:43:37 2013 +0800
+--- a/src/http/ngx_http_spdy.c Fri Dec 20 16:18:25 2013 +0400
++++ b/src/http/ngx_http_spdy.c Sun Dec 22 20:43:37 2013 +0800
@@ -145,8 +145,6 @@
-static void ngx_http_spdy_run_request(ngx_http_request_t *r);
-static ngx_int_t ngx_http_spdy_init_request_body(ngx_http_request_t *r);
+ static void ngx_http_spdy_run_request(ngx_http_request_t *r);
+ static ngx_int_t ngx_http_spdy_init_request_body(ngx_http_request_t *r);
+
-static void ngx_http_spdy_close_stream_handler(ngx_event_t *ev);
-
-static void ngx_http_spdy_handle_connection_handler(ngx_event_t *rev);
-static void ngx_http_spdy_keepalive_handler(ngx_event_t *rev);
-static void ngx_http_spdy_finalize_connection(ngx_http_spdy_connection_t *sc,
+ static void ngx_http_spdy_handle_connection_handler(ngx_event_t *rev);
+ static void ngx_http_spdy_keepalive_handler(ngx_event_t *rev);
+ static void ngx_http_spdy_finalize_connection(ngx_http_spdy_connection_t *sc,
@@ -210,6 +208,12 @@
-c = rev->data;
-hc = c->data;
-+ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_spdy_module);
-+
-+ if (sscf->version == NGX_SPDY_VERSION_V3) {
-+ ngx_http_spdy_v3_init(rev);
-+ return;
-+ }
-ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
-"init spdy request");
+
+ c = rev->data;
+ hc = c->data;
++ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_spdy_module);
++
++ if (sscf->version == NGX_SPDY_VERSION_V3) {
|