diff -Nru squid-1.0.beta13/ChangeLog squid-1.0.beta14/ChangeLog --- squid-1.0.beta13/ChangeLog Fri Jun 7 09:06:49 1996 +++ squid-1.0.beta14/ChangeLog Fri Jun 7 15:35:32 1996 @@ -255,3 +255,11 @@ - Fixed coredump bug where StoreEntry key was free'd too soon. - Fixed UDP_HIT_OBJ bug: cancel the hierarchy timeout and set the ping_status to DONE for UDP_HIT_OBJ replies. + +Changes to squid-1.0.beta14 (June 7, 1996): + + - Fixed coredump bug in icp.c when generating ``Not Modified'' + replies. + - Fixed SSL bug which assumed the requested host name would + already be in the IP cache. + - Fixed names of generated HTTP reply headers. diff -Nru squid-1.0.beta13/include/version.h squid-1.0.beta14/include/version.h --- squid-1.0.beta13/include/version.h Fri Jun 7 09:12:30 1996 +++ squid-1.0.beta14/include/version.h Fri Jun 7 21:44:32 1996 @@ -1,7 +1,7 @@ -/* $Id: version.h,v 1.19.4.12 1996/06/07 16:12:30 wessels Exp $ +/* $Id: version.h,v 1.19.4.13 1996/06/08 04:44:32 wessels Exp $ * * SQUID_VERSION - String for version id of this distribution */ #ifndef SQUID_VERSION -#define SQUID_VERSION "1.0.beta13" +#define SQUID_VERSION "1.0.beta14" #endif diff -Nru squid-1.0.beta13/src/icp.c squid-1.0.beta14/src/icp.c --- squid-1.0.beta13/src/icp.c Thu Jun 6 12:34:58 1996 +++ squid-1.0.beta14/src/icp.c Fri Jun 7 15:30:04 1996 @@ -1,4 +1,4 @@ -/* $Id: icp.c,v 1.61.2.72 1996/06/06 19:34:58 wessels Exp $ */ +/* $Id: icp.c,v 1.61.2.74 1996/06/07 22:30:04 wessels Exp $ */ /* * DEBUG: Section 12 icp: @@ -8,6 +8,7 @@ int neighbors_do_private_keys = 1; +static char NotModified[] = "HTTP/1.0 304 Not Modified\r\n\r\n"; static char *log_tags[] = { "LOG_NONE", @@ -415,12 +416,12 @@ icpStateData *icpState; { StoreEntry *entry = icpState->entry; - char *buf = icpState->buf; + MemObject *mem = entry->mem_obj; int buf_len = icpState->offset; int len; int max_len = 8191 - buf_len; - char *p = buf + buf_len; - char *IMS_hdr; + char *p = icpState->buf + buf_len; + char *IMS_hdr = NULL; time_t IMS; int IMS_length; time_t date; @@ -436,17 +437,14 @@ storeClientCopy(entry, icpState->offset, max_len, p, &len, fd); buf_len = icpState->offset = +len; - if (!mime_headers_end(buf)) { + if (!mime_headers_end(icpState->buf)) { /* All headers are not yet available, wait for more data */ storeRegister(entry, fd, (PIF) icpHandleStoreIMS, (void *) icpState); return COMM_OK; } /* All headers are available, check if object is modified or not */ IMS_hdr = mime_get_header(icpState->request_hdr, "If-Modified-Since"); - httpParseHeaders(buf, entry->mem_obj->reply); - - /* Headers is no longer needed (they are parsed) */ - icpFreeBufOrPage(icpState); + httpParseHeaders(icpState->buf, mem->reply); if (!IMS_hdr) fatal_dump("icpGetHeadersForIMS: Cant find IMS header in request\n"); @@ -455,7 +453,7 @@ /* Only objects with statuscode==200 can be "Not modified" */ /* XXX: Should we ignore this? */ - if (entry->mem_obj->reply->code != 200) + if (mem->reply->code != 200) return icpProcessMISS(fd, icpState); p = strtok(IMS_hdr, ";"); IMS = parse_rfc850(p); @@ -468,25 +466,32 @@ } /* Find date when the object last was modified */ - if (*entry->mem_obj->reply->last_modified) - date = parse_rfc850(entry->mem_obj->reply->last_modified); - else if (*entry->mem_obj->reply->date) - date = parse_rfc850(entry->mem_obj->reply->date); + if (*mem->reply->last_modified) + date = parse_rfc850(mem->reply->last_modified); + else if (*mem->reply->date) + date = parse_rfc850(mem->reply->date); else date = entry->timestamp; /* Find size of the object */ - if (entry->mem_obj->reply->content_length) - length = entry->mem_obj->reply->content_length; + if (mem->reply->content_length) + length = mem->reply->content_length; else - length = entry->object_len - mime_headers_size(buf); + length = entry->object_len - mime_headers_size(icpState->buf); + + /* Headers is no longer needed (they are parsed) */ + icpFreeBufOrPage(icpState); /* Compare with If-Modified-Since header */ if (IMS > date || (IMS == date && (IMS_length < 0 || IMS_length == length))) { /* The object is not modified */ debug(12, 4, "icpGetHeadersForIMS: Not modified '%s'\n", entry->url); - strcpy(buf, "HTTP/1.0 304 Not modified\n\r\n\r"); - comm_write(fd, "HTTP/1.0 304 Not modified\r\n\r\n", strlen("HTTP/1.0 304 Not modified\r\n\r\n"), 30, icpHandleIMSComplete, (void *) icpState); + comm_write(fd, + NotModified, + strlen(NotModified), + 30, + icpHandleIMSComplete, + icpState); return COMM_OK; } else { debug(12, 4, "icpGetHeadersForIMS: We have newer '%s'\n", entry->url); diff -Nru squid-1.0.beta13/src/mime.c squid-1.0.beta14/src/mime.c --- squid-1.0.beta13/src/mime.c Thu Jun 6 12:34:59 1996 +++ squid-1.0.beta14/src/mime.c Fri Jun 7 15:29:43 1996 @@ -1,5 +1,5 @@ -/* $Id: mime.c,v 1.12.2.4 1996/06/06 19:34:59 wessels Exp $ */ +/* $Id: mime.c,v 1.12.2.5 1996/06/07 22:29:43 wessels Exp $ */ /* * DEBUG: Section 25 mime @@ -123,27 +123,39 @@ * returns non-zero on error, or 0 on success. */ int mk_mime_hdr(result, ttl, size, lmt, type) - char *result, *type; + char *result; + char *type; int size; - time_t ttl, lmt; + time_t ttl; + time_t lmt; { time_t expiretime; time_t t; static char date[100]; - static char expire[100]; - static char last_modified_time[100]; + static char expires[100]; + static char last_modified[100]; + static char content_length[100]; if (result == NULL) return 1; - t = squid_curtime; - expiretime = t + ttl; - - date[0] = expire[0] = last_modified_time[0] = result[0] = '\0'; - strncpy(date, mkrfc850(&t), 100); - strncpy(expire, mkrfc850(&expiretime), 100); - strncpy(last_modified_time, mkrfc850(&lmt), 100); - - sprintf(result, "Content-Type: %s\r\nContent-Size: %d\r\nDate: %s\r\nExpires: %s\r\nLast-Modified-Time: %s\r\n", type, size, date, expire, last_modified_time); + expiretime = ttl ? t + ttl : 0; + date[0] = expires[0] = last_modified[0] = '\0'; + content_length[0] = result[0] = '\0'; + sprintf(date, "Date: %s\r\n", mkrfc850(&t)); + if (ttl >= 0) + sprintf(expires, "Expires: %s\r\n", mkrfc850(&expiretime)); + if (lmt) + sprintf(last_modified, "Last-Modified: %s\r\n", mkrfc850(&lmt)); + if (size > 0) + sprintf(content_length, "Content-Length: %d\r\n", size); + sprintf(result, "Server: %s/%s\r\n%s%s%sContent-Type: %s\r\n%s", + appname, + version_string, + date, + expires, + last_modified, + type, + content_length); return 0; } diff -Nru squid-1.0.beta13/src/ssl.c squid-1.0.beta14/src/ssl.c --- squid-1.0.beta13/src/ssl.c Thu Jun 6 15:29:48 1996 +++ squid-1.0.beta14/src/ssl.c Fri Jun 7 15:30:28 1996 @@ -1,6 +1,6 @@ /* - * $Id: ssl.c,v 1.1.2.12 1996/06/06 22:29:48 wessels Exp $ + * $Id: ssl.c,v 1.1.2.14 1996/06/07 22:30:28 wessels Exp $ * * DEBUG: Section 26 ssl */ @@ -29,6 +29,7 @@ static void sslWriteServer _PARAMS((int fd, SslStateData * sslState)); static void sslWriteClient _PARAMS((int fd, SslStateData * sslState)); static void sslConnected _PARAMS((int fd, SslStateData * sslState)); +static int sslConnect _PARAMS((int fd, struct hostent *, SslStateData *)); static void sslConnInProgress _PARAMS((int fd, SslStateData * sslState)); static int sslStateFree(fd, sslState) @@ -302,54 +303,16 @@ return; } - -int sslStart(fd, url, request, mime_hdr, size_ptr) +static int sslConnect(fd, hp, sslState) int fd; - char *url; - request_t *request; - char *mime_hdr; - int *size_ptr; + struct hostent *hp; + SslStateData *sslState; { - /* Create state structure. */ - int sock, status; - SslStateData *sslState = NULL; - - debug(26, 3, "sslStart: '%s %s'\n", - RequestMethodStr[request->method], url); - - /* Create socket. */ - sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url); - if (sock == COMM_ERROR) { - debug(26, 4, "sslStart: Failed because we're out of sockets.\n"); - squid_error_url(url, - request->method, - ERR_NO_FDS, - fd_table[fd].ipaddr, - 500, - xstrerror()); - return COMM_ERROR; - } - sslState = xcalloc(1, sizeof(SslStateData)); - sslState->url = xstrdup(url); - sslState->request = requestLink(request); - sslState->mime_hdr = mime_hdr; - sslState->timeout = getReadTimeout(); - sslState->size_ptr = size_ptr; - sslState->client.fd = fd; - sslState->server.fd = sock; - sslState->server.buf = xmalloc(SQUID_TCP_SO_RCVBUF); - sslState->client.buf = xmalloc(SQUID_TCP_SO_RCVBUF); - comm_set_select_handler(sslState->server.fd, - COMM_SELECT_CLOSE, - (PF) sslStateFree, - (void *) sslState); - - /* check if IP is already in cache. It must be. - * It should be done before this route is called. - * Otherwise, we cannot check return code for ssl. */ + request_t *request = sslState->request; + int status; if (!ipcache_gethostbyname(request->host, 0)) { - debug(26, 4, "sslstart: Called without IP entry in ipcache. OR lookup failed.\n"); - squid_error_url(url, + debug(26, 4, "sslConnect: Unknown host: %s\n", request->host); + squid_error_url(sslState->url, request->method, ERR_DNS_FAIL, fd_table[fd].ipaddr, @@ -357,9 +320,9 @@ dns_error_message); comm_close(sslState->client.fd); comm_close(sslState->server.fd); - return COMM_ERROR; + return 0; } - debug(26, 5, "sslStart: client=%d server=%d\n", + debug(26, 5, "sslConnect: client=%d server=%d\n", sslState->client.fd, sslState->server.fd); /* Install lifetime handler */ @@ -376,9 +339,9 @@ (PF) sslLifetimeExpire, (void *) sslState); /* Open connection. */ - if ((status = comm_connect(sock, request->host, request->port))) { + if ((status = comm_connect(fd, request->host, request->port))) { if (status != EINPROGRESS) { - squid_error_url(url, + squid_error_url(sslState->url, request->method, ERR_CONNECT_FAIL, fd_table[fd].ipaddr, @@ -388,7 +351,7 @@ comm_close(sslState->server.fd); return COMM_ERROR; } else { - debug(26, 5, "sslStart: conn %d EINPROGRESS\n", sock); + debug(26, 5, "sslConnect: conn %d EINPROGRESS\n", fd); /* The connection is in progress, install ssl handler */ comm_set_select_handler(sslState->server.fd, COMM_SELECT_WRITE, @@ -397,7 +360,53 @@ return COMM_OK; } } - /* We got immediately connected. (can this happen?) */ sslConnected(sslState->server.fd, sslState); + return COMM_OK; +} + +int sslStart(fd, url, request, mime_hdr, size_ptr) + int fd; + char *url; + request_t *request; + char *mime_hdr; + int *size_ptr; +{ + /* Create state structure. */ + SslStateData *sslState = NULL; + int sock; + + debug(26, 3, "sslStart: '%s %s'\n", + RequestMethodStr[request->method], url); + + /* Create socket. */ + sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url); + if (sock == COMM_ERROR) { + debug(26, 4, "sslStart: Failed because we're out of sockets.\n"); + squid_error_url(url, + request->method, + ERR_NO_FDS, + fd_table[fd].ipaddr, + 500, + xstrerror()); + return COMM_ERROR; + } + sslState = xcalloc(1, sizeof(SslStateData)); + sslState->url = xstrdup(url); + sslState->request = requestLink(request); + sslState->mime_hdr = mime_hdr; + sslState->timeout = getReadTimeout(); + sslState->size_ptr = size_ptr; + sslState->client.fd = fd; + sslState->server.fd = sock; + sslState->server.buf = xmalloc(SQUID_TCP_SO_RCVBUF); + sslState->client.buf = xmalloc(SQUID_TCP_SO_RCVBUF); + comm_set_select_handler(sslState->server.fd, + COMM_SELECT_CLOSE, + (PF) sslStateFree, + (void *) sslState); + ipcache_nbgethostbyname(request->host, + sslState->server.fd, + (IPH) sslConnect, + sslState); return COMM_OK; }