]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http2: first embryo toward Upgrade:
authorDaniel Stenberg <daniel@haxx.se>
Sat, 7 Sep 2013 09:03:23 +0000 (11:03 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 7 Sep 2013 09:28:12 +0000 (11:28 +0200)
lib/http.c
lib/http2.c
lib/http2.h

index c95616bdda5310b039117bb81a706b24b0795eb2..3b18c63115aa7fbff3e899f9142d51a33afc784b 100644 (file)
@@ -75,6 +75,7 @@
 #include "non-ascii.h"
 #include "bundles.h"
 #include "pipeline.h"
+#include "http2.h"
 
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
@@ -2179,6 +2180,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
   if(result)
     return result;
 
+  if(!(conn->handler->flags&PROTOPT_SSL) &&
+     (data->set.httpversion == CURL_HTTP_VERSION_2_0)) {
+    /* append HTTP2 updrade magic stuff to the HTTP request if it isn't done
+       over SSL */
+    result = Curl_http2_request(req_buffer, conn);
+    if(result)
+      return result;
+  }
+
 #if !defined(CURL_DISABLE_COOKIES)
   if(data->cookies || addcookies) {
     struct Cookie *co=NULL; /* no cookies from start */
index 21be17ba7b392380ac9dfe8a7042cdc53aeb4fe9..1b4300aa9fee00cdc8f67a1d65e7f2bde20a2f0c 100644 (file)
@@ -27,7 +27,9 @@
 #include <curl/mprintf.h>
 
 #include <nghttp2/nghttp2.h>
+#include "urldata.h"
 #include "http2.h"
+#include "http.h"
 
 /*
  * Store nghttp2 version info in this buffer, Prefix with a space.  Return
@@ -39,4 +41,21 @@ int Curl_http2_ver(char *p, size_t len)
   return snprintf(p, len, " nghttp2/%s", h2->version_str);
 }
 
+/*
+ * Append headers to ask for a HTTP1.1 to HTTP2 upgrade.
+ */
+CURLcode Curl_http2_request(Curl_send_buffer *req,
+                            struct connectdata *conn)
+{
+  const char *base64="AABBCC"; /* a fake string to start with */
+  CURLcode result =
+    Curl_add_bufferf(req,
+                     "Connection: Upgrade, HTTP2-Settings\r\n"
+                     "Upgrade: HTTP/2.0\r\n"
+                     "HTTP2-Settings: %s\r\n",
+                     base64);
+  (void)conn;
+  return result;
+}
+
 #endif
index 4ad06c26de0e8a9435eec3e7292dc98762f09872..09b91d11229b93ebc8b1a89ddc6d04ba1ab18d32 100644 (file)
  *
  ***************************************************************************/
 
+#include "curl_setup.h"
+
+#ifdef USE_NGHTTP2
+#include "http.h"
 /*
  * Store nghttp2 version info in this buffer, Prefix with a space.  Return
  * total length written.
  */
 int Curl_http2_ver(char *p, size_t len);
 
+CURLcode Curl_http2_request(Curl_send_buffer *req,
+                            struct connectdata *conn);
+#else /* USE_NGHTTP2 */
+#define Curl_http2_request(x,y) CURLE_OK
+#endif
+
 #endif /* HEADER_CURL_HTTP2_H */