http2: handle 101 responses and switch to HTTP2

This commit is contained in:
Daniel Stenberg 2013-09-12 13:51:04 +02:00
parent 8bcf677a30
commit 8d3608f2ad
4 changed files with 67 additions and 5 deletions

View file

@ -37,6 +37,32 @@
/* include memdebug.h last */
#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