diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
index 00f3626cb573ddc84977f0dae6f35fa2cd8d508f..1a0b96591826daa1e1e40796c388a211856a63a9 100644
--- a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
+++ b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
@@ -30,8 +30,8 @@ int timeout=120; // seconds
 #if constant(SSL.sslfile) 
  import SSL.constants;
  SSL.sslfile ssl;
- int https=0;
 #endif
+int(0..1) https = 0;
 
 object con;
 string request;
@@ -109,18 +109,23 @@ static void connect(string server,int port,int blocking)
 #ifdef HTTP_QUERY_DEBUG
    werror("<- (connect %O:%d)\n",server,port);
 #endif
+
    int success;
-   if (catch { success = con->connect(server,port,blocking); } || !success)
-   {
-      if (!(errno=con->errno())) errno=22; /* EINVAL */
+   if(con->_fd)
+     success = con->connect(server, port);
+   else
+     success = con->connect(server, port, blocking);
+
+   if(!success) {
 #ifdef HTTP_QUERY_DEBUG
-      werror("<- (error %d)\n",errno);
+     werror("<- (connect error)\n");
 #endif
-      destruct(con);
-      con=0;
-      ok=0;
-      return;
+     destruct(con);
+     con = 0;
+     ok = 0;
+     return;
    }
+
 #ifdef HTTP_QUERY_DEBUG
    werror("<- %O\n",request);
 #endif