summaryrefslogtreecommitdiff
path: root/lib/http.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-02-01 00:51:24 +0900
committerDaniel Stenberg <daniel@haxx.se>2014-02-04 14:49:49 +0100
commit63b26d889f58ba25fc45a2ff02ed41ea08c63dbd (patch)
treefe3b19104f012a492eefd7c35f114de86b6b9af5 /lib/http.h
parent4d8db595cab1222927a251a9b836ac4947b7d73d (diff)
downloadgnurl-63b26d889f58ba25fc45a2ff02ed41ea08c63dbd.tar.gz
gnurl-63b26d889f58ba25fc45a2ff02ed41ea08c63dbd.tar.bz2
gnurl-63b26d889f58ba25fc45a2ff02ed41ea08c63dbd.zip
HTTP2: add layer between existing http and socket(TLS) layer
This patch chooses different approach to integrate HTTP2 into HTTP curl stack. The idea is that we insert HTTP2 layer between HTTP code and socket(TLS) layer. When HTTP2 is initialized (either in NPN or Upgrade), we replace the Curl_recv/Curl_send callbacks with HTTP2's, but keep the original callbacks in http_conn struct. When sending serialized data by nghttp2, we use original Curl_send callback. Likewise, when reading data from network, we use original Curl_recv callback. In this way we can treat both TLS and non-TLS connections. With this patch, one can transfer contents from https://twitter.com and from nghttp2 test server in plain HTTP as well. The code still has rough edges. The notable one is I could not figure out how to call nghttp2_session_send() when underlying socket is writable.
Diffstat (limited to 'lib/http.h')
-rw-r--r--lib/http.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/http.h b/lib/http.h
index a32a71d78..d568114d7 100644
--- a/lib/http.h
+++ b/lib/http.h
@@ -149,6 +149,9 @@ struct HTTP {
points to an allocated send_buffer struct */
};
+typedef int (*sending)(void); /* Curl_send */
+typedef int (*recving)(void); /* Curl_recv */
+
struct http_conn {
#ifdef USE_NGHTTP2
#define H2_BINSETTINGS_LEN 80
@@ -158,6 +161,9 @@ struct http_conn {
char *mem; /* points to a buffer in memory to store or read from */
size_t len; /* size of the buffer 'mem' points to */
bool bodystarted;
+ sending send_underlying; /* underlying send Curl_send callback */
+ recving recv_underlying; /* underlying recv Curl_recv callback */
+ bool closed; /* TRUE on HTTP2 stream close */
#else
int unused; /* prevent a compiler warning */
#endif