? configure ? squidintver.diff ? include/autoconf.h.in Index: src/HttpMsg.c =================================================================== RCS file: /cvsroot/squid/squid/src/HttpMsg.c,v retrieving revision 1.3 diff -u -p -r1.3 HttpMsg.c --- src/HttpMsg.c 2000/10/23 15:04:19 1.3 +++ src/HttpMsg.c 2000/11/12 10:37:31 @@ -89,9 +89,9 @@ httpMsgIsolateHeaders(const char **parse /* returns true if connection should be "persistent" * after processing this message */ int -httpMsgIsPersistent(float http_ver, const HttpHeader * hdr) +httpMsgIsPersistent(http_version_t http_ver, const HttpHeader * hdr) { - if (http_ver >= 1.1) { + if ((http_ver.major>=1) && (http_ver.minor >= 1)) { /* * for modern versions of HTTP: persistent unless there is * a "Connection: close" header. Index: src/HttpReply.c =================================================================== RCS file: /cvsroot/squid/squid/src/HttpReply.c,v retrieving revision 1.3 diff -u -p -r1.3 HttpReply.c --- src/HttpReply.c 2000/10/23 15:04:19 1.3 +++ src/HttpReply.c 2000/11/12 10:37:34 @@ -194,7 +194,7 @@ httpReplySwapOut(const HttpReply * rep, } MemBuf -httpPackedReply(double ver, http_status status, const char *ctype, +httpPackedReply(http_version_t ver, http_status status, const char *ctype, int clen, time_t lmt, time_t expires) { HttpReply *rep = httpReplyCreate(); @@ -228,7 +228,7 @@ httpPacked304Reply(const HttpReply * rep } void -httpReplySetHeaders(HttpReply * reply, double ver, http_status status, const char *reason, +httpReplySetHeaders(HttpReply * reply, http_version_t ver, http_status status, const char *reason, const char *ctype, int clen, time_t lmt, time_t expires) { HttpHeader *hdr; @@ -259,8 +259,10 @@ void httpRedirectReply(HttpReply * reply, http_status status, const char *loc) { HttpHeader *hdr; + http_version_t ver; assert(reply); - httpStatusLineSet(&reply->sline, 1.0, status, httpStatusString(status)); + httpBuildVersion(&ver,1,0); + httpStatusLineSet(&reply->sline, ver, status, httpStatusString(status)); hdr = &reply->header; httpHeaderPutStr(hdr, HDR_SERVER, full_appname_string); httpHeaderPutTime(hdr, HDR_DATE, squid_curtime); Index: src/HttpStatusLine.c =================================================================== RCS file: /cvsroot/squid/squid/src/HttpStatusLine.c,v retrieving revision 1.3 diff -u -p -r1.3 HttpStatusLine.c --- src/HttpStatusLine.c 2000/10/23 15:04:19 1.3 +++ src/HttpStatusLine.c 2000/11/12 10:37:34 @@ -37,23 +37,30 @@ /* local constants */ +const char *HttpStatusLineFormat = "HTTP/%d.%d %3d %s\r\n"; +#if 0 const char *HttpStatusLineFormat = "HTTP/%3.1f %3d %s\r\n"; +#endif void httpStatusLineInit(HttpStatusLine * sline) { - httpStatusLineSet(sline, 0.0, HTTP_STATUS_NONE, NULL); + http_version_t version; + httpBuildVersion(&version,0,0); + httpStatusLineSet(sline, version , HTTP_STATUS_NONE, NULL); } void httpStatusLineClean(HttpStatusLine * sline) { - httpStatusLineSet(sline, 0.0, HTTP_INTERNAL_SERVER_ERROR, NULL); + http_version_t version; + httpBuildVersion(&version,0,0); + httpStatusLineSet(sline, version, HTTP_INTERNAL_SERVER_ERROR, NULL); } /* set values */ void -httpStatusLineSet(HttpStatusLine * sline, double version, http_status status, const char *reason) +httpStatusLineSet(HttpStatusLine * sline, http_version_t version, http_status status, const char *reason) { assert(sline); sline->version = version; @@ -68,10 +75,11 @@ httpStatusLinePackInto(const HttpStatusL { assert(sline && p); debug(57, 9) ("packing sline %p using %p:\n", sline, p); - debug(57, 9) (HttpStatusLineFormat, sline->version, sline->status, + debug(57, 9) (HttpStatusLineFormat, sline->version.major, + sline->version.minor, sline->status, sline->reason ? sline->reason : httpStatusString(sline->status)); - packerPrintf(p, HttpStatusLineFormat, - sline->version, sline->status, httpStatusLineReason(sline)); + packerPrintf(p, HttpStatusLineFormat, sline->version.major, + sline->version.minor, sline->status, httpStatusLineReason(sline)); } /* pack fields using Packer */ @@ -85,7 +93,12 @@ httpStatusLineParse(HttpStatusLine * sli start += 5; if (!xisdigit(*start)) return 0; + if (sscanf(start, "%d.%d", &sline->version.major, &sline->version.minor)!=2){ + debug(57, 7) ("httpStatusLineParse: Invalid HTTP identifier.\n"); + } +#if 0 sline->version = atof(start); +#endif if (!(start = strchr(start, ' '))) return 0; sline->status = atoi(++start); Index: src/access_log.c =================================================================== RCS file: /cvsroot/squid/squid/src/access_log.c,v retrieving revision 1.4 diff -u -p -r1.4 access_log.c --- src/access_log.c 2000/11/03 08:39:20 1.4 +++ src/access_log.c 2000/11/12 10:37:34 @@ -215,13 +215,13 @@ accessLogCommon(AccessLogEntry * al) client = fqdncache_gethostbyaddr(al->cache.caddr, 0); if (client == NULL) client = inet_ntoa(al->cache.caddr); - logfilePrintf(logfile, "%s %s - [%s] \"%s %s HTTP/%.1f\" %d %d %s:%s", + logfilePrintf(logfile, "%s %s - [%s] \"%s %s HTTP/%d.%d\" %d %d %s:%s", client, al->cache.ident, mkhttpdlogtime(&squid_curtime), al->private.method_str, al->url, - al->http.version, + al->http.version.major, al->http.version.minor, al->http.code, al->cache.size, log_tags[al->cache.code], Index: src/cache_manager.c =================================================================== RCS file: /cvsroot/squid/squid/src/cache_manager.c,v retrieving revision 1.3 diff -u -p -r1.3 cache_manager.c --- src/cache_manager.c 2000/10/23 15:04:20 1.3 +++ src/cache_manager.c 2000/11/12 10:37:35 @@ -253,11 +253,13 @@ cachemgrStart(int fd, request_t * reques if (a->flags.atomic) storeBuffer(entry); { + http_version_t version; HttpReply *rep = entry->mem_obj->reply; /* prove there are no previous reply headers around */ assert(0 == rep->sline.status); + httpBuildVersion(&version,1,0); httpReplySetHeaders(rep, - (double) 1.0, + version, HTTP_OK, NULL, "text/plain", Index: src/client_side.c =================================================================== RCS file: /cvsroot/squid/squid/src/client_side.c,v retrieving revision 1.5 diff -u -p -r1.5 client_side.c --- src/client_side.c 2000/11/09 23:26:26 1.5 +++ src/client_side.c 2000/11/12 10:37:50 @@ -575,6 +575,7 @@ clientPurgeRequest(clientHttpRequest * h ErrorState *err = NULL; HttpReply *r; http_status status; + http_version_t version; debug(33, 3) ("Config2.onoff.enable_purge = %d\n", Config2.onoff.enable_purge); if (!Config2.onoff.enable_purge) { http->log_type = LOG_TCP_DENIED; @@ -602,7 +603,8 @@ clientPurgeRequest(clientHttpRequest * h */ http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); httpReplyReset(r = http->entry->mem_obj->reply); - httpReplySetHeaders(r, 1.0, status, NULL, NULL, 0, 0, -1); + httpBuildVersion(&version,1,0); + httpReplySetHeaders(r, version, status, NULL, NULL, 0, 0, -1); httpReplySwapOut(r, http->entry); storeComplete(http->entry); } @@ -917,8 +919,8 @@ clientSetKeepaliveFlag(clientHttpRequest { request_t *request = http->request; const HttpHeader *req_hdr = &request->header; - debug(33, 3) ("clientSetKeepaliveFlag: http_ver = %3.1f\n", - request->http_ver); + debug(33, 3) ("clientSetKeepaliveFlag: http_ver = %d.%d\n", + request->http_ver.major, request->http_ver.minor); debug(33, 3) ("clientSetKeepaliveFlag: method = %s\n", RequestMethodStr[request->method]); if (!Config.onoff.client_pconns) @@ -1277,7 +1279,7 @@ clientBuildReply(clientHttpRequest * htt size_t k = headersEnd(buf, size); if (k && httpReplyParse(rep, buf, k)) { /* enforce 1.0 reply version */ - rep->sline.version = 1.0; + httpBuildVersion(&rep->sline.version,1,0); /* do header conversions */ clientBuildReplyHeader(http, rep); /* if we do ranges, change status to "Partial Content" */ @@ -2075,6 +2077,7 @@ clientProcessRequest(clientHttpRequest * request_t *r = http->request; int fd = http->conn->fd; HttpReply *rep; + http_version_t version; debug(33, 4) ("clientProcessRequest: %s '%s'\n", RequestMethodStr[r->method], url); @@ -2091,7 +2094,8 @@ clientProcessRequest(clientHttpRequest * storeReleaseRequest(http->entry); storeBuffer(http->entry); rep = httpReplyCreate(); - httpReplySetHeaders(rep, 1.0, HTTP_OK, NULL, "text/plain", + httpBuildVersion(&version,1,0); + httpReplySetHeaders(rep, version, HTTP_OK, NULL, "text/plain", httpRequestPrefixLen(r), 0, squid_curtime); httpReplySwapOut(rep, http->entry); httpReplyDestroy(rep); @@ -2227,7 +2231,7 @@ parseHttpRequest(ConnStateData * conn, m char *mstr = NULL; char *url = NULL; char *req_hdr = NULL; - float http_ver; + http_version_t http_ver; char *token = NULL; char *t = NULL; char *end; @@ -2304,12 +2308,19 @@ parseHttpRequest(ConnStateData * conn, m if (token == NULL) { debug(33, 3) ("parseHttpRequest: Missing HTTP identifier\n"); #if RELAXED_HTTP_PARSER - http_ver = (float) 0.9; /* wild guess */ + httpBuildVersion(&http_ver,0,9); /* wild guess */ #else return parseHttpRequestAbort(conn, "error:missing-http-ident"); #endif } else { + if (sscanf(token+5, "%d.%d", &http_ver.major, &http_ver.minor)!=2){ + debug(33, 3) ("parseHttpRequest: Invalid HTTP identifier.\n"); + return parseHttpRequestAbort(conn, "error: invalid HTTP-ident"); + } + debug(33, 6) ("parseHttpRequest: Client HTTP version %d.%d.\n",http_ver.major, http_ver.minor); +#if 0 http_ver = (float) atof(token + 5); +#endif } /* Index: src/errorpage.c =================================================================== RCS file: /cvsroot/squid/squid/src/errorpage.c,v retrieving revision 1.4 diff -u -p -r1.4 errorpage.c --- src/errorpage.c 2000/11/04 23:23:06 1.4 +++ src/errorpage.c 2000/11/12 10:37:50 @@ -499,10 +499,10 @@ errorConvert(char token, ErrorState * er case 'R': if (NULL != r) { Packer p; - memBufPrintf(&mb, "%s %s HTTP/%3.1f\n", + memBufPrintf(&mb, "%s %s HTTP/%d.%d\n", RequestMethodStr[r->method], strLen(r->urlpath) ? strBuf(r->urlpath) : "/", - (double) r->http_ver); + r->http_ver.major, r->http_ver.minor); packerToMemInit(&p, &mb); httpHeaderPackInto(&r->header, &p); packerClean(&p); @@ -574,8 +574,10 @@ errorBuildReply(ErrorState * err) { HttpReply *rep = httpReplyCreate(); MemBuf content = errorBuildContent(err); + http_version_t version; /* no LMT for error pages; error pages expire immediately */ - httpReplySetHeaders(rep, 1.0, err->http_status, NULL, "text/html", content.size, 0, squid_curtime); + httpBuildVersion(&version,1,0); + httpReplySetHeaders(rep, version, err->http_status, NULL, "text/html", content.size, 0, squid_curtime); /* * include some information for downstream caches. Implicit * replaceable content. This isn't quite sufficient. xerrno is not Index: src/ftp.c =================================================================== RCS file: /cvsroot/squid/squid/src/ftp.c,v retrieving revision 1.4 diff -u -p -r1.4 ftp.c --- src/ftp.c 2000/11/04 23:23:06 1.4 +++ src/ftp.c 2000/11/12 10:37:51 @@ -2462,6 +2462,7 @@ ftpAppendSuccessHeader(FtpStateData * ft StoreEntry *e = ftpState->entry; StoreEntry *pe = NULL; http_reply *reply = e->mem_obj->reply; + http_version_t version; if (ftpState->flags.http_header_sent) return; ftpState->flags.http_header_sent = 1; @@ -2493,12 +2494,14 @@ ftpAppendSuccessHeader(FtpStateData * ft HttpHdrRangeSpec range_spec; range_spec.offset = ftpState->restarted_offset; range_spec.length = ftpState->size - ftpState->restarted_offset; - httpReplySetHeaders(reply, 1.0, HTTP_PARTIAL_CONTENT, "Gatewaying", + httpBuildVersion(&version,1,0); + httpReplySetHeaders(reply, version, HTTP_PARTIAL_CONTENT, "Gatewaying", mime_type, ftpState->size - ftpState->restarted_offset, ftpState->mdtm, -2); httpHeaderAddContRange(&reply->header, range_spec, ftpState->size); } else { /* Full reply */ - httpReplySetHeaders(reply, 1.0, HTTP_OK, "Gatewaying", + httpBuildVersion(&version,1,0); + httpReplySetHeaders(reply, version, HTTP_OK, "Gatewaying", mime_type, ftpState->size, ftpState->mdtm, -2); } /* additional info */ Index: src/http.c =================================================================== RCS file: /cvsroot/squid/squid/src/http.c,v retrieving revision 1.4 diff -u -p -r1.4 http.c --- src/http.c 2000/11/03 08:39:20 1.4 +++ src/http.c 2000/11/12 10:37:56 @@ -1017,3 +1017,9 @@ httpSendRequestEntryDone(int fd, char *b comm_write(fd, "\r\n", 2, httpSendComplete, data, NULL); } } + +void +httpBuildVersion(http_version_t *version, unsigned int major,unsigned int minor) { + version->major=major; + version->minor=minor; +} Index: src/internal.c =================================================================== RCS file: /cvsroot/squid/squid/src/internal.c,v retrieving revision 1.3 diff -u -p -r1.3 internal.c --- src/internal.c 2000/10/23 15:04:21 1.3 +++ src/internal.c 2000/11/12 10:37:56 @@ -44,6 +44,7 @@ internalStart(request_t * request, Store { ErrorState *err; const char *upath = strBuf(request->urlpath); + http_version_t version; debug(76, 3) ("internalStart: %s requesting '%s'\n", inet_ntoa(request->client_addr), upath); if (0 == strcmp(upath, "/squid-internal-dynamic/netdb")) { @@ -54,8 +55,9 @@ internalStart(request_t * request, Store #else const char *msgbuf = "This cache does not suport Cache Digests.\n"; #endif + httpBuildVersion(&version,1,0); httpReplySetHeaders(entry->mem_obj->reply, - 1.0, + version, HTTP_NOT_FOUND, "Not Found", "text/plain", Index: src/mime.c =================================================================== RCS file: /cvsroot/squid/squid/src/mime.c,v retrieving revision 1.3 diff -u -p -r1.3 mime.c --- src/mime.c 2000/10/23 15:04:21 1.3 +++ src/mime.c 2000/11/12 10:37:59 @@ -394,6 +394,7 @@ mimeLoadIconFile(const char *icon) char *buf; const char *type = mimeGetContentType(icon); HttpReply *reply; + http_version_t version; if (type == NULL) fatal("Unknown icon format while reading mime.conf\n"); buf = internalLocalUri("/squid-internal-static/icons/", icon); @@ -421,7 +422,8 @@ mimeLoadIconFile(const char *icon) storeBuffer(e); e->mem_obj->request = requestLink(urlParse(METHOD_GET, url)); httpReplyReset(reply = e->mem_obj->reply); - httpReplySetHeaders(reply, 1.0, HTTP_OK, NULL, + httpBuildVersion(&version,1,0); + httpReplySetHeaders(reply, version, HTTP_OK, NULL, type, (int) sb.st_size, sb.st_mtime, -1); reply->cache_control = httpHdrCcCreate(); httpHdrCcSetMaxAge(reply->cache_control, 86400); Index: src/net_db.c =================================================================== RCS file: /cvsroot/squid/squid/src/net_db.c,v retrieving revision 1.5 diff -u -p -r1.5 net_db.c --- src/net_db.c 2000/11/03 08:39:20 1.5 +++ src/net_db.c 2000/11/12 10:38:02 @@ -919,6 +919,7 @@ void netdbBinaryExchange(StoreEntry * s) { http_reply *reply = s->mem_obj->reply; + http_version_t version; #if USE_ICMP netdbEntry *n; int i; @@ -928,7 +929,8 @@ netdbBinaryExchange(StoreEntry * s) struct in_addr addr; storeBuffer(s); httpReplyReset(reply); - httpReplySetHeaders(reply, 1.0, HTTP_OK, "OK", + httpBuildVersion(version,1,0); + httpReplySetHeaders(reply, version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2); httpReplySwapOut(reply, s); rec_sz = 0; @@ -970,7 +972,8 @@ netdbBinaryExchange(StoreEntry * s) memFree(buf, MEM_4K_BUF); #else httpReplyReset(reply); - httpReplySetHeaders(reply, 1.0, HTTP_BAD_REQUEST, "Bad Request", + httpBuildVersion(&version,1,0); + httpReplySetHeaders(reply, version, HTTP_BAD_REQUEST, "Bad Request", NULL, -1, squid_curtime, -2); storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n"); #endif Index: src/protos.h =================================================================== RCS file: /cvsroot/squid/squid/src/protos.h,v retrieving revision 1.4 diff -u -p -r1.4 protos.h --- src/protos.h 2000/11/03 08:39:20 1.4 +++ src/protos.h 2000/11/12 10:38:05 @@ -269,6 +269,7 @@ extern int gopherCachable(const char *); extern void whoisStart(FwdState *); +/* http.c */ extern int httpCachable(method_t); extern void httpStart(FwdState *); extern void httpParseReplyHeaders(const char *, http_reply *); @@ -283,6 +284,7 @@ extern void httpAnonInitModule(void); extern int httpAnonHdrAllowed(http_hdr_type hdr_id); extern int httpAnonHdrDenied(http_hdr_type hdr_id); extern void httpBuildRequestHeader(request_t *, request_t *, StoreEntry *, HttpHeader *, int, http_state_flags); +extern void httpBuildVersion(http_version_t *version,unsigned int major,unsigned int minor); /* ETag */ extern int etagParseInit(ETag * etag, const char *str); @@ -293,7 +295,7 @@ extern int etagIsEqual(const ETag * tag1 extern void httpStatusLineInit(HttpStatusLine * sline); extern void httpStatusLineClean(HttpStatusLine * sline); /* set/get values */ -extern void httpStatusLineSet(HttpStatusLine * sline, double version, +extern void httpStatusLineSet(HttpStatusLine * sline, http_version_t version, http_status status, const char *reason); extern const char *httpStatusLineReason(const HttpStatusLine * sline); /* parse/pack */ @@ -432,7 +434,7 @@ extern void httpHeaderEntryPackInto(cons extern void httpHeaderStoreReport(StoreEntry * e); /* Http Msg (currently in HttpReply.c @?@ ) */ -extern int httpMsgIsPersistent(float http_ver, const HttpHeader * hdr); +extern int httpMsgIsPersistent(http_version_t http_ver, const HttpHeader * hdr); extern int httpMsgIsolateHeaders(const char **parse_start, const char **blk_start, const char **blk_end); /* Http Reply */ @@ -453,10 +455,10 @@ extern MemBuf httpReplyPack(const HttpRe /* swap: create swap-based packer, pack, destroy packer */ extern void httpReplySwapOut(const HttpReply * rep, StoreEntry * e); /* set commonly used info with one call */ -extern void httpReplySetHeaders(HttpReply * rep, double ver, http_status status, +extern void httpReplySetHeaders(HttpReply * rep, http_version_t ver, http_status status, const char *reason, const char *ctype, int clen, time_t lmt, time_t expires); /* do everything in one call: init, set, pack, clean, return MemBuf */ -extern MemBuf httpPackedReply(double ver, http_status status, const char *ctype, +extern MemBuf httpPackedReply(http_version_t ver, http_status status, const char *ctype, int clen, time_t lmt, time_t expires); /* construct 304 reply and pack it into MemBuf, return MemBuf */ extern MemBuf httpPacked304Reply(const HttpReply * rep); Index: src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.6 diff -u -p -r1.6 structs.h --- src/structs.h 2000/11/10 16:36:45 1.6 +++ src/structs.h 2000/11/12 10:38:09 @@ -93,6 +93,11 @@ struct _String { char *buf; }; +struct _http_version_t { + unsigned int major; + unsigned int minor; +}; + #if SQUID_SNMP struct _snmp_request_t { @@ -650,7 +655,10 @@ struct _Packer { /* http status line */ struct _HttpStatusLine { /* public, read only */ + http_version_t version; +#if 0 float version; +#endif const char *reason; /* points to a _constant_ string (default or supplied), never free()d */ http_status status; }; @@ -775,6 +783,7 @@ struct _HttpReply { HttpBody body; /* for small constant memory-resident text bodies only */ }; + struct _http_state_flags { unsigned int proxying:1; unsigned int keepalive:1; @@ -838,7 +847,10 @@ struct _AccessLogEntry { method_t method; int code; const char *content_type; + http_version_t version; +#if 0 float version; +#endif } http; struct { icp_opcode opcode; @@ -880,7 +892,7 @@ struct _clientHttpRequest { const char *lookup_type; /* temporary hack: storeGet() result: HIT/MISS/NONE */ #endif struct timeval start; - float http_ver; + http_version_t http_ver; int redirect_state; aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */ clientHttpRequest *next; @@ -1436,7 +1448,7 @@ struct _request_t { request_flags flags; HttpHdrCc *cache_control; HttpHdrRange *range; - float http_ver; + http_version_t http_ver; time_t ims; int imslen; int max_forwards; Index: src/typedefs.h =================================================================== RCS file: /cvsroot/squid/squid/src/typedefs.h,v retrieving revision 1.3 diff -u -p -r1.3 typedefs.h --- src/typedefs.h 2000/10/23 15:04:22 1.3 +++ src/typedefs.h 2000/11/12 10:38:09 @@ -177,6 +177,8 @@ typedef struct _RemovalPurgeWalker Remov typedef struct _RemovalPolicyNode RemovalPolicyNode; typedef struct _RemovalPolicySettings RemovalPolicySettings; +typedef struct _http_version_t http_version_t; + #if SQUID_SNMP typedef variable_list *(oid_ParseFn) (variable_list *, snint *); typedef struct _snmp_request_t snmp_request_t; Index: src/urn.c =================================================================== RCS file: /cvsroot/squid/squid/src/urn.c,v retrieving revision 1.3 diff -u -p -r1.3 urn.c --- src/urn.c 2000/10/23 15:04:22 1.3 +++ src/urn.c 2000/11/12 10:38:09 @@ -185,6 +185,7 @@ urnHandleReply(void *data, char *buf, ss ErrorState *err; int i; int urlcnt = 0; + http_version_t version; debug(52, 3) ("urnHandleReply: Called with size=%d.\n", size); if (EBIT_TEST(urlres_e->flags, ENTRY_ABORTED)) { @@ -272,7 +273,8 @@ urnHandleReply(void *data, char *buf, ss full_appname_string, getMyHostname()); rep = e->mem_obj->reply; httpReplyReset(rep); - httpReplySetHeaders(rep, 1.0, HTTP_MOVED_TEMPORARILY, NULL, + httpBuildVersion(&version,1,0); + httpReplySetHeaders(rep, version, HTTP_MOVED_TEMPORARILY, NULL, "text/html", mb.size, 0, squid_curtime); if (urnState->flags.force_menu) { debug(51, 3) ("urnHandleReply: forcing menu\n");