X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Fconnection.c;h=82b13bf0d04f5a316968bb18577378a2d47f8c47;hb=69fd741a9dd52b132ea733638ae3839971ef5baf;hp=e053df2ee23e187a9399acc39c4cc403149c01a8;hpb=d0b5d139253e5c599c9e675fc0a5677bda5a5a29;p=tlsproxy%2Ftlsproxy.git diff --git a/src/connection.c b/src/connection.c index e053df2..82b13bf 100644 --- a/src/connection.c +++ b/src/connection.c @@ -164,6 +164,7 @@ void handle_connection(int client_socket) { if (global_proxy_host != NULL && global_proxy_port != NULL) { fprintf(server_fd, "CONNECT %s:%s HTTP/1.0\r\n", host, port); fprintf(server_fd, "\r\n"); + fflush(server_fd); /* Read response line from proxy server. */ result = read_http_request(server_fd, buffer, sizeof(buffer)); @@ -524,6 +525,7 @@ static void send_bad_request(FILE *client_fd) { fprintf(client_fd, HTTP_RESPONSE_FORMAT, RESPONSE_ERROR, RESPONSE_ERROR, RESPONSE_ERROR, RESPONSE_MSG); + fflush(client_fd); #undef RESPONSE_ERROR #undef RESPONSE_MSG } @@ -533,6 +535,7 @@ static void send_forwarding_failure(FILE *client_fd) { fprintf(client_fd, HTTP_RESPONSE_FORMAT, RESPONSE_ERROR, RESPONSE_ERROR, RESPONSE_ERROR, RESPONSE_MSG); + fflush(client_fd); #undef RESPONSE_ERROR #undef RESPONSE_MSG } @@ -625,9 +628,8 @@ static int read_from_write_to(int from, int to) { if (size_read < 0) { LOG_PERROR(LOG_WARNING, "read_from_write_to(): read()"); return -1; - } /* EOF */ - if (size_read == 0) { + } else if (size_read == 0) { return -1; } @@ -722,9 +724,8 @@ static int read_from_write_to_tls(gnutls_session_t from, LOG(LOG_WARNING, "read_from_write_to_tls(): gnutls_record_recv(): %s", gnutls_strerror((int)size_read)); return -1; - } /* EOF */ - if (size_read == 0) { + } else if (size_read == 0) { return -1; }