X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fconnection.c;h=418c424c03e3d3f362cc7f9d9b22ac466951689c;hb=1c56e6d7e4f7f80eab3a630ce81b2b6481072121;hp=65714c7b6421dec5705cb1f9b3d6c8699446cfcc;hpb=4aa2eea6b3115cab6f3165c4391d523d5df61e51;p=tlsproxy%2Ftlsproxy.git
diff --git a/src/connection.c b/src/connection.c
index 65714c7..418c424 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -17,11 +17,9 @@
* along with this program. If not, see .
*/
-#include
+#include "tlsproxy.h"
+#include "connection.h"
-#include
-#include
-#include
/* close() */
#include
/* getaddrinfo() */
@@ -29,13 +27,10 @@
/* poll() */
#include
-#include "connection.h"
-#include "tlsproxy.h"
-
-/* Maximum line of the request line. Longer request lines are aborted with an
- * error. The standard doesn't specify a maximum line length but this should
- * be a good limit to make processing simpler. */
+/* Maximum line of a HTTP request line. Longer request lines are aborted with
+ * an error. The standard doesn't specify a maximum line length but this
+ * should be a good limit to make processing simpler. */
#define MAX_REQUEST_LINE 4096
@@ -76,10 +71,10 @@ void handle_connection(int client_socket) {
/* Read request line (CONNECT ..) and headers (they are discarded). */
result = read_http_request(client_fd, buffer, sizeof(buffer));
- if (result == -1) {
- /* Read error. */
+ if (-1 == result) {
+ /* Read error, client_fd already closed. */
return;
- } else if (result == -2) {
+ } else if (-2 == result) {
/* EOF */
send_close_bad_request(client_fd);
return;
@@ -125,11 +120,11 @@ void handle_connection(int client_socket) {
/* Read response line from proxy server. */
result = read_http_request(server_fd, buffer, sizeof(buffer));
- if (result == -1) {
- /* Read error. */
+ if (-1 == result) {
+ /* Read error, server_fd already closed. */
send_close_forwarding_failure(client_fd);
return;
- } else if (result == -2) {
+ } else if (-2 == result) {
/* EOF */
fclose(server_fd);
send_close_forwarding_failure(client_fd);
@@ -343,7 +338,7 @@ static int connect_to_host(const char *hostname, const char *port) {
/* Parse HTTP CONNECT request string and save its parameters.
*
- * The following format is expected: "CONNECT host:port HTTP/1.y".
+ * The following format is expected: "CONNECT host:port HTTP/1.x".
*
* request and host must have the same size! port must be at least 6 bytes
* long (5 + '\0').