]> granicus.if.org Git - curl/commitdiff
http2: use CURL_HTTP_VERSION_* symbols instead of NPN_*
authorDaniel Stenberg <daniel@haxx.se>
Sat, 7 Mar 2015 10:10:30 +0000 (11:10 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 7 Mar 2015 10:10:30 +0000 (11:10 +0100)
Since they already exist and will make comparing easier

lib/http.c
lib/urldata.h
lib/vtls/gtls.c
lib/vtls/nss.c
lib/vtls/openssl.c
lib/vtls/polarssl.c

index e673a069b0b0241b89caab6116477d0b51d57b65..dff164b5e55ec0c34ec40f1e479b48311a19f5c6 100644 (file)
@@ -1795,7 +1795,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
   if(conn->httpversion < 20) { /* unless the connection is re-used and already
                                   http2 */
     switch(conn->negnpn) {
-    case NPN_HTTP2:
+    case CURL_HTTP_VERSION_2_0:
       result = Curl_http2_init(conn);
       if(result)
         return result;
@@ -1808,7 +1808,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
       if(result)
         return result;
       break;
-    case NPN_HTTP1_1:
+    case CURL_HTTP_VERSION_1_1:
       /* continue with HTTP/1.1 when explicitly requested */
       break;
     default:
index 37081c1b86aae6ab38fcb2bc845280afce8ea663..202d81951bd8e657334b019f220ee5760863b93f 100644 (file)
@@ -600,12 +600,6 @@ enum upgrade101 {
   UPGR101_WORKING             /* talking upgraded protocol */
 };
 
-enum negotiatenpn {
-  NPN_INIT,                   /* default state */
-  NPN_HTTP1_1,                /* HTTP/1.1 negotiated */
-  NPN_HTTP2                   /* HTTP2 (draft-xx) negotiated */
-};
-
 /*
  * Request specific data in the easy handle (SessionHandle).  Previously,
  * these members were on the connectdata struct but since a conn struct may
@@ -1067,7 +1061,7 @@ struct connectdata {
   } tunnel_state[2]; /* two separate ones to allow FTP */
   struct connectbundle *bundle; /* The bundle we are member of */
 
-  enum negotiatenpn negnpn;
+  int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */
 };
 
 /* The end of connectdata. */
index 232e57357e1ef4e5fb6889e9957dac79874db90a..05aef19676c540d4c0d4414285d76961360ca053 100644 (file)
@@ -1073,13 +1073,13 @@ gtls_connect_step3(struct connectdata *conn,
       if(proto.size == NGHTTP2_PROTO_VERSION_ID_LEN &&
          !memcmp(NGHTTP2_PROTO_VERSION_ID, proto.data,
                  NGHTTP2_PROTO_VERSION_ID_LEN)) {
-        conn->negnpn = NPN_HTTP2;
+        conn->negnpn = CURL_HTTP_VERSION_2_0;
       }
       else
 #endif
       if(proto.size == ALPN_HTTP_1_1_LENGTH &&
          !memcmp(ALPN_HTTP_1_1, proto.data, ALPN_HTTP_1_1_LENGTH)) {
-        conn->negnpn = NPN_HTTP1_1;
+        conn->negnpn = CURL_HTTP_VERSION_1_1;
       }
     }
     else
index 86bdb54d4a63e58ddb4d1bc7a89a1dd81cb7f90b..d1309dd04df16872a59db8bcdcf24f7da0b136d3 100644 (file)
@@ -717,13 +717,13 @@ static void HandshakeCallback(PRFileDesc *sock, void *arg)
 #ifdef USE_NGHTTP2
     if(buflen == NGHTTP2_PROTO_VERSION_ID_LEN &&
        !memcmp(NGHTTP2_PROTO_VERSION_ID, buf, NGHTTP2_PROTO_VERSION_ID_LEN)) {
-      conn->negnpn = NPN_HTTP2;
+      conn->negnpn = CURL_HTTP_VERSION_2_0;
     }
     else
 #endif
     if(buflen == ALPN_HTTP_1_1_LENGTH &&
        !memcmp(ALPN_HTTP_1_1, buf, ALPN_HTTP_1_1_LENGTH)) {
-      conn->negnpn = NPN_HTTP1_1;
+      conn->negnpn = CURL_HTTP_VERSION_1_1;
     }
   }
 }
index 862a73ce3b80c0dd35db7332959bf815df20fc27..2d41ed4a51f59596ab1c143a4622b76ca6d71385 100644 (file)
@@ -1645,7 +1645,7 @@ select_next_proto_cb(SSL *ssl,
                            NGHTTP2_PROTO_VERSION_ID_LEN)) {
     infof(conn->data, "NPN, negotiated HTTP2 (%s)\n",
           NGHTTP2_PROTO_VERSION_ID);
-    conn->negnpn = NPN_HTTP2;
+    conn->negnpn = CURL_HTTP_VERSION_2_0;
     return SSL_TLSEXT_ERR_OK;
   }
 #endif
@@ -1653,14 +1653,14 @@ select_next_proto_cb(SSL *ssl,
   if(!select_next_protocol(out, outlen, in, inlen, ALPN_HTTP_1_1,
                            ALPN_HTTP_1_1_LENGTH)) {
     infof(conn->data, "NPN, negotiated HTTP1.1\n");
-    conn->negnpn = NPN_HTTP1_1;
+    conn->negnpn = CURL_HTTP_VERSION_1_1;
     return SSL_TLSEXT_ERR_OK;
   }
 
   infof(conn->data, "NPN, no overlap, use HTTP1.1\n");
   *out = (unsigned char *)ALPN_HTTP_1_1;
   *outlen = ALPN_HTTP_1_1_LENGTH;
-  conn->negnpn = NPN_HTTP1_1;
+  conn->negnpn = CURL_HTTP_VERSION_1_1;
 
   return SSL_TLSEXT_ERR_OK;
 }
@@ -2225,13 +2225,13 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
 #ifdef USE_NGHTTP2
         if(len == NGHTTP2_PROTO_VERSION_ID_LEN &&
            !memcmp(NGHTTP2_PROTO_VERSION_ID, neg_protocol, len)) {
-          conn->negnpn = NPN_HTTP2;
+          conn->negnpn = CURL_HTTP_VERSION_2_0;
         }
         else
 #endif
         if(len == ALPN_HTTP_1_1_LENGTH &&
            !memcmp(ALPN_HTTP_1_1, neg_protocol, ALPN_HTTP_1_1_LENGTH)) {
-          conn->negnpn = NPN_HTTP1_1;
+          conn->negnpn = CURL_HTTP_VERSION_1_1;
         }
       }
       else
index b7f2f6c9419da526da6713eba8b13d173b0fd0a0..cafcec2b3290225ad4f1d8406aa77506f4c72326 100644 (file)
@@ -469,12 +469,12 @@ polarssl_connect_step2(struct connectdata *conn,
 #ifdef USE_NGHTTP2
       if(!strncmp(next_protocol, NGHTTP2_PROTO_VERSION_ID,
                   NGHTTP2_PROTO_VERSION_ID_LEN)) {
-        conn->negnpn = NPN_HTTP2;
+        conn->negnpn = CURL_HTTP_VERSION_2_0;
       }
       else
 #endif
       if(!strncmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)) {
-        conn->negnpn = NPN_HTTP1_1;
+        conn->negnpn = CURL_HTTP_VERSION_1_1;
       }
     }
     else