mirror of
https://github.com/moparisthebest/curl
synced 2024-11-12 04:25:08 -05:00
polarssl: make it possible to enable ALPN/NPN without HTTP2
This commit is contained in:
parent
42bc45be8e
commit
adb4e41a1a
@ -118,11 +118,8 @@ static void polarssl_debug(void *context, int level, const char *line)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ALPN for http2? */
|
/* ALPN for http2? */
|
||||||
#ifdef USE_NGHTTP2
|
#ifdef POLARSSL_SSL_ALPN
|
||||||
# undef HAS_ALPN
|
# define HAS_ALPN
|
||||||
# ifdef POLARSSL_SSL_ALPN
|
|
||||||
# define HAS_ALPN
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Curl_recv polarssl_recv;
|
static Curl_recv polarssl_recv;
|
||||||
@ -357,16 +354,23 @@ polarssl_connect_step1(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_ALPN
|
#ifdef HAS_ALPN
|
||||||
if(data->set.httpversion == CURL_HTTP_VERSION_2_0) {
|
if(data->set.ssl_enable_alpn) {
|
||||||
if(data->set.ssl_enable_alpn) {
|
static const char* protocols[3];
|
||||||
static const char* protocols[] = {
|
int cur = 0;
|
||||||
NGHTTP2_PROTO_VERSION_ID, ALPN_HTTP_1_1, NULL
|
|
||||||
};
|
#ifdef USE_NGHTTP2
|
||||||
ssl_set_alpn_protocols(&connssl->ssl, protocols);
|
if(data->set.httpversion == CURL_HTTP_VERSION_2_0) {
|
||||||
infof(data, "ALPN, offering %s, %s\n", protocols[0],
|
protocols[cur++] = NGHTTP2_PROTO_VERSION_ID;
|
||||||
protocols[1]);
|
infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID);
|
||||||
connssl->asked_for_h2 = TRUE;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protocols[cur++] = ALPN_HTTP_1_1;
|
||||||
|
infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
|
||||||
|
|
||||||
|
protocols[cur] = NULL;
|
||||||
|
|
||||||
|
ssl_set_alpn_protocols(&connssl->ssl, protocols);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -388,10 +392,6 @@ polarssl_connect_step2(struct connectdata *conn,
|
|||||||
struct ssl_connect_data* connssl = &conn->ssl[sockindex];
|
struct ssl_connect_data* connssl = &conn->ssl[sockindex];
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
|
||||||
#ifdef HAS_ALPN
|
|
||||||
const char* next_protocol;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char errorbuf[128];
|
char errorbuf[128];
|
||||||
errorbuf[0] = 0;
|
errorbuf[0] = 0;
|
||||||
|
|
||||||
@ -461,22 +461,24 @@ polarssl_connect_step2(struct connectdata *conn,
|
|||||||
|
|
||||||
#ifdef HAS_ALPN
|
#ifdef HAS_ALPN
|
||||||
if(data->set.ssl_enable_alpn) {
|
if(data->set.ssl_enable_alpn) {
|
||||||
next_protocol = ssl_get_alpn_protocol(&connssl->ssl);
|
const char *next_protocol = ssl_get_alpn_protocol(&connssl->ssl);
|
||||||
|
|
||||||
if(next_protocol != NULL) {
|
if(next_protocol != NULL) {
|
||||||
infof(data, "ALPN, server accepted to use %s\n", next_protocol);
|
infof(data, "ALPN, server accepted to use %s\n", next_protocol);
|
||||||
|
|
||||||
|
#ifdef USE_NGHTTP2
|
||||||
if(!strncmp(next_protocol, NGHTTP2_PROTO_VERSION_ID,
|
if(!strncmp(next_protocol, NGHTTP2_PROTO_VERSION_ID,
|
||||||
NGHTTP2_PROTO_VERSION_ID_LEN)) {
|
NGHTTP2_PROTO_VERSION_ID_LEN)) {
|
||||||
conn->negnpn = NPN_HTTP2;
|
conn->negnpn = NPN_HTTP2;
|
||||||
}
|
}
|
||||||
else if(!strncmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)) {
|
else
|
||||||
|
#endif
|
||||||
|
if(!strncmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)) {
|
||||||
conn->negnpn = NPN_HTTP1_1;
|
conn->negnpn = NPN_HTTP1_1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(connssl->asked_for_h2) {
|
else
|
||||||
infof(data, "ALPN, server did not agree to a protocol\n");
|
infof(data, "ALPN, server did not agree to a protocol\n");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user