Binary files squid-1.0.alpha15/src/.nfs5A05 and squid-1.0.alpha15.henrik/src/.nfs5A05 differ diff -N -c -r -X exclude_files squid-1.0.alpha15/src/connect.c squid-1.0.alpha15.henrik/src/connect.c *** squid-1.0.alpha15/src/connect.c Fri Apr 12 23:41:36 1996 --- squid-1.0.alpha15.henrik/src/connect.c Mon Apr 15 21:52:58 1996 *************** *** 32,39 **** static void connectReadTimeout _PARAMS((int fd, ConnectData * data)); static void connectSendRemote _PARAMS((int fd, ConnectData * data)); static void connectReadClient _PARAMS((int fd, ConnectData * data)); ! static void connectConnectTimeout _PARAMS((int fd, ConnectData * data)); ! static void connectConnectRemote _PARAMS((int fd, ConnectData * data)); static void connectCloseAndFree _PARAMS((int fd, ConnectData * data)); extern intlist *connect_port_list; --- 32,39 ---- static void connectReadTimeout _PARAMS((int fd, ConnectData * data)); static void connectSendRemote _PARAMS((int fd, ConnectData * data)); static void connectReadClient _PARAMS((int fd, ConnectData * data)); ! static void connectConnected _PARAMS((int fd, ConnectData * data)); ! static void connectConnInProgress _PARAMS((int fd, ConnectData * data)); static void connectCloseAndFree _PARAMS((int fd, ConnectData * data)); extern intlist *connect_port_list; *************** *** 54,60 **** atypebuf[0] = hostbuf[0] = request[0] = host[0] = '\0'; t = sscanf(url, "%[a-zA-Z]://%[^/]%s", atypebuf, hostbuf, request); ! if ((t < 2) || (strcasecmp(atypebuf, "conne") != 0)) { return -1; } else if (t == 2) { strcpy(request, "/"); --- 54,60 ---- atypebuf[0] = hostbuf[0] = request[0] = host[0] = '\0'; t = sscanf(url, "%[a-zA-Z]://%[^/]%s", atypebuf, hostbuf, request); ! if ((t < 2) || (strcasecmp(atypebuf, "connect") != 0)) { return -1; } else if (t == 2) { strcpy(request, "/"); *************** *** 243,257 **** connectCloseAndFree(fd, data); } ! static void connectConnectTimeout(fd, data) ! int fd; ! ConnectData *data; ! { ! cached_error_entry(data->entry, ERR_CONNECT_FAIL, xstrerror()); ! connectCloseAndFree(fd, data); ! } ! ! static void connectConnectRemote(fd, data) int fd; ConnectData *data; { --- 243,249 ---- connectCloseAndFree(fd, data); } ! static void connectConnected(fd, data) int fd; ConnectData *data; { *************** *** 282,287 **** --- 274,312 ---- safe_free(data); } + void connectConnInProgress(fd, data) + int fd; + ConnectData *data; + { + debug(26, 5, "connectConnInProgress: FD %d data=%p\n", fd, data); + + if(comm_connect(fd, data->host, data->port) != COMM_OK) { + debug(26, 5, "connectConnInProgress: FD %d errno=%d", fd, errno); + switch(errno) { + case EINPROGRESS: + case EALREADY: + /* We are not connectedd yet. schedule this handler again */ + comm_set_select_handler(fd, COMM_SELECT_WRITE, + (PF) connectConnInProgress, + (void *) data); + return; + case EISCONN: + /* We are connected (doesn't comm_connect return + * COMM_OK on EISCONN?) + */ + break; + default: + cached_error_entry(data->entry, ERR_CONNECT_FAIL, xstrerror()); + connectCloseAndFree(fd, data); + return; + } + } + + /* We are now fully connected */ + connectConnected(fd, data); + return; + } + int connectStart(fd, url, method, mime_hdr, entry) int fd; char *url; *************** *** 317,322 **** --- 342,348 ---- safe_free(data); return COMM_ERROR; } + data->remote = sock; #ifdef STAT_FD_ASSOC stat_fd_assoc(fd, sock); #endif *************** *** 330,335 **** --- 356,365 ---- connectCloseAndFree(sock, data); return COMM_ERROR; } + debug(26, 5, "connectStart: client=%d remote=%d\n", fd, sock); + /* Install lifetime handler */ + comm_set_select_handler(sock, COMM_SELECT_LIFETIME, + (PF) connectLifetimeExpire, (void *) data); /* Open connection. */ if ((status = comm_connect(sock, data->host, data->port))) { if (status != EINPROGRESS) { *************** *** 338,361 **** return COMM_ERROR; } else { debug(26, 5, "connectStart: conn %d EINPROGRESS\n", sock); ! return COMM_OK; } } ! data->remote = sock; ! /* Install connection complete handler. */ ! debug(26, 5, "connectStart: client=%d remote=%d\n", fd, sock); ! comm_set_select_handler(sock, ! COMM_SELECT_LIFETIME, ! (PF) connectLifetimeExpire, ! (void *) data); ! comm_set_select_handler_plus_timeout(sock, ! COMM_SELECT_TIMEOUT, ! (PF) connectConnectTimeout, ! (void *) data, ! data->timeout); ! comm_set_select_handler(sock, ! COMM_SELECT_WRITE, ! (PF) connectConnectRemote, ! (void *) data); return COMM_OK; } --- 368,379 ---- return COMM_ERROR; } else { debug(26, 5, "connectStart: conn %d EINPROGRESS\n", sock); ! /* The connection is in progress, install connect handler */ ! comm_set_select_handler(sock, COMM_SELECT_WRITE, ! (PF) connectConnInProgress, (void *) data); } } ! /* We got immediately connected. (can this happen?) */ ! connectConnected(sock,data); return COMM_OK; } diff -N -c -r -X exclude_files squid-1.0.alpha15/src/icp.c squid-1.0.alpha15.henrik/src/icp.c *** squid-1.0.alpha15/src/icp.c Sun Apr 14 05:05:03 1996 --- squid-1.0.alpha15.henrik/src/icp.c Mon Apr 15 20:17:37 1996 *************** *** 175,180 **** --- 175,182 ---- return gopherCachable(request); if (!strncasecmp(request, "wais://", 7)) return 0; + if (!strncasecmp(request, "connect://", 10)) + return 0; if (!strncasecmp(request, "cache_object://", 15)) return 0; return 1; *************** *** 1206,1214 **** --- 1208,1228 ---- return 0; } /* Assign icpState->url */ + if (icpState->method == METHOD_CONNECT) { + /* Prepend the host name with connect:// on CONNECT */ + t=xmalloc(strlen(request)+strlen("connect://")); + strcpy(t,"connect://"); + strcat(t,request); + if(free_request) + safe_free(request); + request=t; + free_request=1; + } if ((ad = getAppendDomain())) { if ((t = do_append_domain(request, ad))) { + if(free_request) + safe_free(request); request = t; free_request = 1; /* NOTE: We don't have to free the old request pointer *************** *** 1276,1282 **** char *t = NULL; protocol_t protocol; int port; ! if (sscanf(astm->url, "%[^:]://%[^/]%s", proto, host, urlpath) != 3) return ERR_INVALID_URL; for (t = host; *t; t++) *t = tolower(*t); --- 1290,1297 ---- char *t = NULL; protocol_t protocol; int port; ! *urlpath=0; ! if (sscanf(astm->url, "%[^:]://%[^/]%s", proto, host, urlpath) < 2) return ERR_INVALID_URL; for (t = host; *t; t++) *t = tolower(*t); diff -N -c -r -X exclude_files squid-1.0.alpha15/src/proto.c squid-1.0.alpha15.henrik/src/proto.c *** squid-1.0.alpha15/src/proto.c Fri Apr 12 06:53:49 1996 --- squid-1.0.alpha15.henrik/src/proto.c Mon Apr 15 19:54:17 1996 *************** *** 66,72 **** return gopherCachable(url); if (!strncasecmp(url, "wais://", 7)) return 0; ! if (!strncasecmp(url, "conne://", 8)) return 0; if (!strncasecmp(url, "cache_object://", 15)) return 0; --- 66,72 ---- return gopherCachable(url); if (!strncasecmp(url, "wais://", 7)) return 0; ! if (!strncasecmp(url, "connect://", 8)) return 0; if (!strncasecmp(url, "cache_object://", 15)) return 0; *************** *** 469,475 **** return ftpStart(fd, url, entry); } else if (strncasecmp(url, "wais://", 7) == 0) { return waisStart(fd, url, entry->method, request_hdr, entry); ! } else if (strncasecmp(url, "conne://", 8) == 0) { return connectStart(fd, url, entry->method, request_hdr, entry); } else if (strncasecmp(url, "dht://", 6) == 0) { return protoNotImplemented(fd, url, entry); --- 469,475 ---- return ftpStart(fd, url, entry); } else if (strncasecmp(url, "wais://", 7) == 0) { return waisStart(fd, url, entry->method, request_hdr, entry); ! } else if (strncasecmp(url, "connect://", 8) == 0) { return connectStart(fd, url, entry->method, request_hdr, entry); } else if (strncasecmp(url, "dht://", 6) == 0) { return protoNotImplemented(fd, url, entry); diff -N -c -r -X exclude_files squid-1.0.alpha15/src/store.c squid-1.0.alpha15.henrik/src/store.c *** squid-1.0.alpha15/src/store.c Mon Apr 15 22:49:41 1996 --- squid-1.0.alpha15.henrik/src/store.c Mon Apr 15 20:32:34 1996 *************** *** 514,519 **** --- 514,523 ---- sprintf(key_temp_buffer, "/head/%s", url); return key_temp_buffer; break; + case METHOD_CONNECT: + sprintf(key_temp_buffer, "/connect/%s", url); + return key_temp_buffer; + break; default: fatal_dump("storeGeneratePublicKey: Unsupported request method"); break; diff -N -c -r -X exclude_files squid-1.0.alpha15/src/store.h squid-1.0.alpha15.henrik/src/store.h *** squid-1.0.alpha15/src/store.h Sun Apr 14 05:03:47 1996 --- squid-1.0.alpha15.henrik/src/store.h Mon Apr 15 20:50:06 1996 *************** *** 115,121 **** enum { NO_SWAP, SWAPPING_OUT, SWAP_OK } swap_status:3; ! int method:3; /* WARNING: Explicit assummption that fewer than 256 * WARNING: clients all hop onto the same object. The code --- 115,121 ---- enum { NO_SWAP, SWAPPING_OUT, SWAP_OK } swap_status:3; ! unsigned int method:3; /* WARNING: Explicit assummption that fewer than 256 * WARNING: clients all hop onto the same object. The code diff -N -c -r -X exclude_files squid-1.0.alpha15/src/url.c squid-1.0.alpha15.henrik/src/url.c *** squid-1.0.alpha15/src/url.c Fri Apr 12 06:53:53 1996 --- squid-1.0.alpha15.henrik/src/url.c Mon Apr 15 19:54:37 1996 *************** *** 143,149 **** "NONE", "GET", "POST", ! "HEAD" }; char *ProtocolStr[] = --- 143,150 ---- "NONE", "GET", "POST", ! "HEAD", ! "CONNECT" }; char *ProtocolStr[] = *************** *** 165,170 **** --- 166,173 ---- return METHOD_POST; } else if (strcasecmp(s, "HEAD") == 0) { return METHOD_HEAD; + } else if (strcasecmp(s, "CONNECT") == 0) { + return METHOD_CONNECT; } return METHOD_NONE; } *************** *** 183,188 **** --- 186,193 ---- return PROTO_CACHEOBJ; if (strncasecmp(s, "file", 4) == 0) return PROTO_FTP; + if (strncasecmp(s, "connect", 7) == 0) + return PROTO_CONNECT; return PROTO_NONE; } diff -N -c -r -X exclude_files squid-1.0.alpha15/src/url.h squid-1.0.alpha15.henrik/src/url.h *** squid-1.0.alpha15/src/url.h Fri Apr 12 00:53:42 1996 --- squid-1.0.alpha15.henrik/src/url.h Mon Apr 15 19:44:30 1996 *************** *** 7,13 **** METHOD_NONE, METHOD_GET, METHOD_POST, ! METHOD_HEAD } method_t; extern char *RequestMethodStr[]; --- 7,14 ---- METHOD_NONE, METHOD_GET, METHOD_POST, ! METHOD_HEAD, ! METHOD_CONNECT } method_t; extern char *RequestMethodStr[]; *************** *** 19,24 **** --- 20,26 ---- PROTO_GOPHER, PROTO_WAIS, PROTO_CACHEOBJ, + PROTO_CONNECT, PROTO_MAX } protocol_t;