aboutsummaryrefslogtreecommitdiff
path: root/lib/http2.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-09-12 13:51:04 +0200
committerDaniel Stenberg <daniel@haxx.se>2014-01-29 10:24:05 +0100
commit8d3608f2ad29bb65ce0926a45b46ff29902c279f (patch)
tree1d9ddec9546056b9ad7d6d94b545e0492c7ebe95 /lib/http2.c
parent8bcf677a30cc1559b635c0eca7dd29ac2ab5f4bb (diff)
http2: handle 101 responses and switch to HTTP2
Diffstat (limited to 'lib/http2.c')
-rw-r--r--lib/http2.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/http2.c b/lib/http2.c
index b876436e1..f15cb1700 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -38,6 +38,32 @@
#include "memdebug.h"
/*
+ * HTTP2 handler interface. This isn't added to the general list of protocols
+ * but will be used at run-time when the protocol is dynamically switched from
+ * HTTP to HTTP2.
+ */
+const struct Curl_handler Curl_handler_http2 = {
+ "HTTP2", /* scheme */
+ ZERO_NULL, /* setup_connection */
+ ZERO_NULL, /* do_it */
+ ZERO_NULL , /* done */
+ ZERO_NULL, /* do_more */
+ ZERO_NULL, /* connect_it */
+ ZERO_NULL, /* connecting */
+ ZERO_NULL, /* doing */
+ ZERO_NULL, /* proto_getsock */
+ ZERO_NULL, /* doing_getsock */
+ ZERO_NULL, /* domore_getsock */
+ ZERO_NULL, /* perform_getsock */
+ ZERO_NULL, /* disconnect */
+ ZERO_NULL, /* readwrite */
+ PORT_HTTP, /* defport */
+ 0, /* protocol */
+ PROTOPT_NONE /* flags */
+};
+
+
+/*
* Store nghttp2 version info in this buffer, Prefix with a space. Return
* total length written.
*/
@@ -138,6 +164,7 @@ CURLcode Curl_http2_request(Curl_send_buffer *req,
ssize_t binlen;
char *base64;
size_t blen;
+ struct SingleRequest *k = &conn->data->req;
if(!conn->proto.httpc.h2) {
/* The nghttp2 session is not yet setup, do it */
@@ -176,7 +203,16 @@ CURLcode Curl_http2_request(Curl_send_buffer *req,
NGHTTP2_PROTO_VERSION_ID, base64);
free(base64);
+ k->upgr101 = UPGR101_REQUESTED;
+
return result;
}
+void Curl_http2_switched(struct connectdata *conn)
+{
+ /* we are switched! */
+ conn->handler = &Curl_handler_http2;
+ infof(conn->data, "We have switched to HTTP2\n");
+}
+
#endif