]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/blobdiff - tests/client.c
tests: Add tlsproxy_setup() helper function.
[tlsproxy/tlsproxy.git] / tests / client.c
index f98711fa02ffbf09afbafad2ed6a9577b152984c..c11684d2e19bd57d7a60f422601b8aefe7386a8e 100644 (file)
@@ -185,7 +185,12 @@ static int connect_to_host(const char *hostname, const char *port) {
                           | AI_V4MAPPED;   /* support IPv4 through IPv6 */
     gai_return = getaddrinfo(hostname, port, &gai_hints, &gai_result);
     if (gai_return != 0) {
-        perror("connect_to_host(): getaddrinfo()");
+        if (gai_return == EAI_SYSTEM) {
+            perror("connect_to_host(): getaddrinfo()");
+        } else {
+            fprintf(stderr, "connect_to_host(): getaddrinfo(): %s",
+                            gai_strerror(gai_return));
+        }
         return -1;
     }
 
@@ -226,11 +231,11 @@ static int read_http_request(FILE *client_fd, char *request, size_t length) {
             perror("read_http_request(): fgets()");
             return -1;
         }
-
+        /* EOF */
         return -2;
     }
 
-    while (fgets(buffer, MAX_REQUEST_LINE, client_fd) != NULL) {
+    while (fgets(buffer, sizeof(buffer), client_fd) != NULL) {
         /* End of header. */
         if (!strcmp(buffer, "\n") || !strcmp(buffer, "\r\n")) {
             break;