From 33580f746af0104b9cd00fd8cc60520306084589 Mon Sep 17 00:00:00 2001 From: Julien <120588494+julien4215@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:21:34 +0100 Subject: [PATCH] more tweaks --- corkwin.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/corkwin.c b/corkwin.c index 42c31a4..06a45fc 100644 --- a/corkwin.c +++ b/corkwin.c @@ -139,15 +139,12 @@ int __cdecl main(int argc, char **argv) { char uri[BUFSIZE] = "", buffer[BUFSIZE] = "", version[BUFSIZE] = "", descr[BUFSIZE] = ""; char *host = NULL, *port = NULL, *desthost = NULL, *destport = NULL; - char *up = NULL, line[4096]; - int sent, setup, code; - fd_set rfd, sfd; + int code; + fd_set rfd; struct timeval tv; ssize_t len; FILE *fp; - port = "80"; - if (argc == 5) { host = argv[1]; port = argv[2]; @@ -211,7 +208,7 @@ int __cdecl main(int argc, char **argv) { strncat(uri, desthost, sizeof(uri) - strlen(uri) - 1); strncat(uri, ":", sizeof(uri) - strlen(uri) - 1); strncat(uri, destport, sizeof(uri) - strlen(uri) - 1); - strncat(uri, " HTTP/1.0", sizeof(uri) - strlen(uri) - 1); + strncat(uri, " HTTP/1.1", sizeof(uri) - strlen(uri) - 1); strncat(uri, linefeed, sizeof(uri) - strlen(uri) - 1); iResult = send(ConnectSocket, uri, (int)strlen(uri), 0); @@ -226,14 +223,11 @@ int __cdecl main(int argc, char **argv) { if (iResult > 0) { memset(descr, 0, sizeof(descr)); sscanf(buffer, "%s%d%[^\n]", version, &code, descr); - if ((strncmp(version, "HTTP/", 5) == 0) && (code >= 200) && (code < 300)) - setup = 1; - else { - if ((strncmp(version, "HTTP/", 5) == 0) && (code >= 407)) { - } + if ((strncmp(version, "HTTP/", 5) != 0) || + !((code >= 200) && (code < 300))) { fprintf(stderr, "Proxy could not open connection to %s: %s\n", desthost, descr); - exit(-1); + return -1; } } else if (iResult == 0) fprintf(stderr, "Connection closed\n");