]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
connect: store connection info when really done
authorStefan Eissing <stefan@eissing.org>
Fri, 13 Sep 2024 11:12:50 +0000 (13:12 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 13 Sep 2024 20:27:11 +0000 (22:27 +0200)
Output the 'Connected to...' info message when the connection has been
fully established and all information is available.

Due to our happy eyeballing, we should not emit info messages in
filters, because they may be part of an eyeballing attempt and may be
discarded later for another chain.

Closes #14897

lib/cf-https-connect.c
lib/cfilters.c
lib/connect.c
lib/url.c

index facb3da270296dfb5613b91b843822f5aea8d0c2..bc7159872026282373e578c8a4e4c6e665daf21a 100644 (file)
@@ -189,7 +189,6 @@ static CURLcode baller_connected(struct Curl_cfilter *cf,
 
   switch(cf->conn->alpn) {
   case CURL_HTTP_VERSION_3:
-    infof(data, "using HTTP/3");
     break;
   case CURL_HTTP_VERSION_2:
 #ifdef USE_NGHTTP2
@@ -202,10 +201,8 @@ static CURLcode baller_connected(struct Curl_cfilter *cf,
       return result;
     }
 #endif
-    infof(data, "using HTTP/2");
     break;
   default:
-    infof(data, "using HTTP/1.x");
     break;
   }
   ctx->state = CF_HC_SUCCESS;
index bed59f9fbbd9ba3f22caa6107b33d905fe27ea1e..3d7da0c69c7adc04a95281ec4ced5f880842506a 100644 (file)
@@ -437,6 +437,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data,
       cf_cntrl_update_info(data, data->conn);
       conn_report_connect_stats(data, data->conn);
       data->conn->keepalive = Curl_now();
+      Curl_verboseconnect(data, data->conn, sockindex);
     }
     else if(result) {
       conn_report_connect_stats(data, data->conn);
index 20275163b52cdcffc171295fb9cc6a7c7a353851..923f37ac3b9348052dde9fd825f905e52b71038d 100644 (file)
@@ -969,7 +969,17 @@ static CURLcode cf_he_connect(struct Curl_cfilter *cf,
 
         if(cf->conn->handler->protocol & PROTO_FAMILY_SSH)
           Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */
-        Curl_verboseconnect(data, cf->conn, cf->sockindex);
+        if(Curl_trc_cf_is_verbose(cf, data)) {
+          struct ip_quadruple ipquad;
+          int is_ipv6;
+          if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) {
+            const char *host, *disphost;
+            int port;
+            cf->next->cft->get_host(cf->next, data, &host, &disphost, &port);
+            CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u",
+                        disphost, ipquad.remote_ip, ipquad.remote_port);
+          }
+        }
         data->info.numconnects++; /* to track the # of connections made */
       }
       break;
index 57aeb7c96144a70d0718cb47ddfb53d8e237c6f7..3bf0c0598552d4087e1176b828edce6c601afc35 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1274,6 +1274,21 @@ void Curl_verboseconnect(struct Curl_easy *data,
     infof(data, "Connected to %s (%s) port %u",
           CURL_CONN_HOST_DISPNAME(conn), conn->primary.remote_ip,
           conn->primary.remote_port);
+#if !defined(CURL_DISABLE_HTTP)
+    if(conn->handler->protocol & PROTO_FAMILY_HTTP) {
+      switch(conn->alpn) {
+      case CURL_HTTP_VERSION_3:
+        infof(data, "using HTTP/3");
+        break;
+      case CURL_HTTP_VERSION_2:
+        infof(data, "using HTTP/2");
+        break;
+      default:
+        infof(data, "using HTTP/1.x");
+        break;
+      }
+    }
+#endif
 }
 #endif