Copilot commented on code in PR #2316:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2316#discussion_r4739758196


##########
core-framework/src/http/HTTPClient.cpp:
##########
@@ -376,6 +376,44 @@ bool HTTPClient::submit() {
   return true;
 }
 
+bool HTTPClient::lastAttemptFailedToConnect() const {
+  switch (res_) {
+    case CURLE_COULDNT_CONNECT:
+    case CURLE_COULDNT_RESOLVE_HOST:
+    case CURLE_COULDNT_RESOLVE_PROXY:
+    case CURLE_SSL_CONNECT_ERROR:
+      return true;
+    case CURLE_OPERATION_TIMEDOUT:
+      return response_data_.response_code == 0;
+    default:
+      return false;
+  }
+}
+
+bool HTTPClient::probeConnection() {
+  if (url_.empty()) {
+    return false;
+  }
+  const std::unique_ptr<CURL, CurlEasyCleanup> 
probe_session{curl_easy_duphandle(http_session_.get())};
+  if (!probe_session) {
+    return false;
+  }
+  curl_easy_setopt(probe_session.get(), CURLOPT_HTTPHEADER, nullptr);
+  curl_easy_setopt(probe_session.get(), CURLOPT_MIMEPOST, nullptr);
+  curl_easy_setopt(probe_session.get(), CURLOPT_NOPROGRESS, 1L);
+  curl_easy_setopt(probe_session.get(), CURLOPT_NOSIGNAL, 1L);
+  curl_easy_setopt(probe_session.get(), CURLOPT_CONNECT_ONLY, 1L);
+  curl_easy_setopt(probe_session.get(), CURLOPT_CONNECTTIMEOUT_MS, 
connect_timeout_.count());
+  curl_easy_setopt(probe_session.get(), CURLOPT_TIMEOUT_MS, 
connect_timeout_.count());
+  curl_easy_setopt(probe_session.get(), CURLOPT_URL, url_.c_str());

Review Comment:
   When a static URL redirects to an unreachable destination, this connect-only 
probe checks only the reachable original URL. It therefore succeeds and 
InvokeHTTP keeps dequeuing FlowFiles into failure instead of yielding. Probe 
the failed transfer's effective URL using `CURLINFO_EFFECTIVE_URL`, and add a 
regression test with a reachable redirector and an unreachable target.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to