diff options
Diffstat (limited to 'libs/libcurl/src/connect.c')
| -rw-r--r-- | libs/libcurl/src/connect.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/libs/libcurl/src/connect.c b/libs/libcurl/src/connect.c index 6fcdd3eac7..4c29377783 100644 --- a/libs/libcurl/src/connect.c +++ b/libs/libcurl/src/connect.c @@ -78,14 +78,32 @@ #include "vquic/vquic.h" /* for quic cfilters */
#include "http_proxy.h"
#include "socks.h"
+#include "strcase.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
-#ifndef ARRAYSIZE
-#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
+#if !defined(CURL_DISABLE_ALTSVC) || defined(USE_HTTPSRR)
+
+enum alpnid Curl_alpn2alpnid(char *name, size_t len)
+{
+ if(len == 2) {
+ if(strncasecompare(name, "h1", 2))
+ return ALPN_h1;
+ if(strncasecompare(name, "h2", 2))
+ return ALPN_h2;
+ if(strncasecompare(name, "h3", 2))
+ return ALPN_h3;
+ }
+ else if(len == 8) {
+ if(strncasecompare(name, "http/1.1", 8))
+ return ALPN_h1;
+ }
+ return ALPN_none; /* unknown, probably rubbish input */
+}
+
#endif
/*
@@ -622,7 +640,7 @@ evaluate: *connected = FALSE; /* a negative world view is best */
now = Curl_now();
ongoing = not_started = 0;
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
if(!baller || baller->is_done)
@@ -683,7 +701,7 @@ evaluate: if(not_started > 0) {
int added = 0;
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
if(!baller || baller->has_started)
@@ -717,7 +735,7 @@ evaluate: /* all ballers have failed to connect. */
CURL_TRC_CF(data, cf, "all eyeballers failed");
result = CURLE_COULDNT_CONNECT;
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
if(!baller)
continue;
@@ -862,7 +880,7 @@ static void cf_he_ctx_clear(struct Curl_cfilter *cf, struct Curl_easy *data) DEBUGASSERT(ctx);
DEBUGASSERT(data);
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
baller_free(ctx->baller[i], data);
ctx->baller[i] = NULL;
}
@@ -885,7 +903,7 @@ static CURLcode cf_he_shutdown(struct Curl_cfilter *cf, /* shutdown all ballers that have not done so already. If one fails,
* continue shutting down others until all are shutdown. */
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
bool bdone = FALSE;
if(!baller || !baller->cf || baller->shutdown)
@@ -896,12 +914,12 @@ static CURLcode cf_he_shutdown(struct Curl_cfilter *cf, }
*done = TRUE;
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
if(ctx->baller[i] && !ctx->baller[i]->shutdown)
*done = FALSE;
}
if(*done) {
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
if(ctx->baller[i] && ctx->baller[i]->result)
result = ctx->baller[i]->result;
}
@@ -918,7 +936,7 @@ static void cf_he_adjust_pollset(struct Curl_cfilter *cf, size_t i;
if(!cf->connected) {
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
if(!baller || !baller->cf)
continue;
@@ -940,7 +958,7 @@ static CURLcode cf_he_connect(struct Curl_cfilter *cf, return CURLE_OK;
}
- (void)blocking; /* TODO: do we want to support this? */
+ (void)blocking;
DEBUGASSERT(ctx);
*done = FALSE;
@@ -1015,7 +1033,7 @@ static bool cf_he_data_pending(struct Curl_cfilter *cf, if(cf->connected)
return cf->next->cft->has_data_pending(cf->next, data);
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
if(!baller || !baller->cf)
continue;
@@ -1034,7 +1052,7 @@ static struct curltime get_max_baller_time(struct Curl_cfilter *cf, size_t i;
memset(&tmax, 0, sizeof(tmax));
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
memset(&t, 0, sizeof(t));
@@ -1059,7 +1077,7 @@ static CURLcode cf_he_query(struct Curl_cfilter *cf, int reply_ms = -1;
size_t i;
- for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
+ for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
struct eyeballer *baller = ctx->baller[i];
int breply_ms;
@@ -1193,7 +1211,7 @@ struct transport_provider transport_providers[] = { static cf_ip_connect_create *get_cf_create(int transport)
{
size_t i;
- for(i = 0; i < ARRAYSIZE(transport_providers); ++i) {
+ for(i = 0; i < CURL_ARRAYSIZE(transport_providers); ++i) {
if(transport == transport_providers[i].transport)
return transport_providers[i].cf_create;
}
@@ -1447,7 +1465,7 @@ void Curl_debug_set_transport_provider(int transport, cf_ip_connect_create *cf_create)
{
size_t i;
- for(i = 0; i < ARRAYSIZE(transport_providers); ++i) {
+ for(i = 0; i < CURL_ARRAYSIZE(transport_providers); ++i) {
if(transport == transport_providers[i].transport) {
transport_providers[i].cf_create = cf_create;
return;
@@ -1485,7 +1503,7 @@ CURLcode Curl_conn_setup(struct Curl_easy *data, DEBUGASSERT(data);
DEBUGASSERT(conn->handler);
-#if !defined(CURL_DISABLE_HTTP) && !defined(USE_HYPER)
+#if !defined(CURL_DISABLE_HTTP)
if(!conn->cfilter[sockindex] &&
conn->handler->protocol == CURLPROTO_HTTPS) {
DEBUGASSERT(ssl_mode != CURL_CF_SSL_DISABLE);
@@ -1493,7 +1511,7 @@ CURLcode Curl_conn_setup(struct Curl_easy *data, if(result)
goto out;
}
-#endif /* !defined(CURL_DISABLE_HTTP) && !defined(USE_HYPER) */
+#endif /* !defined(CURL_DISABLE_HTTP) */
/* Still no cfilter set, apply default. */
if(!conn->cfilter[sockindex]) {
|
