]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert http_ver from a float to http_version_t which is a struct containing
authoradrian <>
Mon, 13 Nov 2000 19:25:11 +0000 (19:25 +0000)
committeradrian <>
Mon, 13 Nov 2000 19:25:11 +0000 (19:25 +0000)
two integers.

Submitted by: Robert Collins <robert.collins@itdomain.com.au>

16 files changed:
src/HttpMsg.cc
src/HttpReply.cc
src/HttpStatusLine.cc
src/access_log.cc
src/cache_manager.cc
src/client_side.cc
src/errorpage.cc
src/ftp.cc
src/http.cc
src/internal.cc
src/mime.cc
src/net_db.cc
src/protos.h
src/structs.h
src/typedefs.h
src/urn.cc

index d7e4f4585f48d0b353907f131836aec8fe4989e8..a9e50d18b9eb6fe6da1338a488029a31776ebdc1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.cc,v 1.7 2000/03/06 16:23:28 wessels Exp $
+ * $Id: HttpMsg.cc,v 1.8 2000/11/13 12:25:11 adrian Exp $
  *
  * DEBUG: section 74    HTTP Message
  * AUTHOR: Alex Rousskov
@@ -89,9 +89,9 @@ httpMsgIsolateHeaders(const char **parse_start, const char **blk_start, const ch
 /* 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 aeaac4079252c9ec0b0ff652ffaae3458cc0b191..c91f31a747cc8aa2ff2a78999d03f6e05cd963a9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.cc,v 1.42 2000/05/16 07:06:02 wessels Exp $
+ * $Id: HttpReply.cc,v 1.43 2000/11/13 12:25:11 adrian Exp $
  *
  * DEBUG: section 58    HTTP Reply (Response)
  * AUTHOR: Alex Rousskov
@@ -194,7 +194,7 @@ httpReplySwapOut(const HttpReply * rep, StoreEntry * e)
 }
 
 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 6775b5dacf1d20ea45757129a2e6736a491cfbbd..3b9101a970ce64b488d86a7801b44b38d4c8e886 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpStatusLine.cc,v 1.19 2000/03/06 16:23:28 wessels Exp $
+ * $Id: HttpStatusLine.cc,v 1.20 2000/11/13 12:25:11 adrian Exp $
  *
  * DEBUG: section 57    HTTP Status-line
  * AUTHOR: Alex Rousskov
 
 
 /* local constants */
-const char *HttpStatusLineFormat = "HTTP/%3.1f %3d %s\r\n";
+const char *HttpStatusLineFormat = "HTTP/%d.%d %3d %s\r\n";
 
 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 +72,11 @@ httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p)
 {
     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 +90,9 @@ httpStatusLineParse(HttpStatusLine * sline, const char *start, const char *end)
     start += 5;
     if (!xisdigit(*start))
        return 0;
-    sline->version = atof(start);
+    if (sscanf(start, "%d.%d", &sline->version.major, &sline->version.minor)!=2){
+        debug(57, 7) ("httpStatusLineParse: Invalid HTTP identifier.\n");
+    }
     if (!(start = strchr(start, ' ')))
        return 0;
     sline->status = atoi(++start);
index d62e77a8472678ecbe5939a69e1a7302344d4a44..cb780576271e2d110387418aa8101dcc3ca31bec 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: access_log.cc,v 1.61 2000/11/01 04:50:25 wessels Exp $
+ * $Id: access_log.cc,v 1.62 2000/11/13 12:25:11 adrian Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -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 9cdd9aa72a897f451e0a6b6bbbd128f149df056a..43caa145de91b732b105615bfae19dba5696e82b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_manager.cc,v 1.22 2000/05/16 07:06:03 wessels Exp $
+ * $Id: cache_manager.cc,v 1.23 2000/11/13 12:25:11 adrian Exp $
  *
  * DEBUG: section 16    Cache Manager Objects
  * AUTHOR: Duane Wessels
@@ -253,11 +253,13 @@ cachemgrStart(int fd, request_t * request, StoreEntry * entry)
     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 348332afd5f731d1f488b8b46d19d6143dc18f4e..0802e3a48ab77be6f700a3286b934e6115642026 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.511 2000/11/09 20:20:52 wessels Exp $
+ * $Id: client_side.cc,v 1.512 2000/11/13 12:25:11 adrian Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -575,6 +575,7 @@ clientPurgeRequest(clientHttpRequest * http)
     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 * http)
      */
     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 * http)
 {
     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 * http, const char *buf, size_t size)
     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 * http)
     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 * http)
            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, method_t * method_p, int *status,
     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,16 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
     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 {
-       http_ver = (float) atof(token + 5);
+        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);
     }
 
     /*
index a0b8be61ce0cc37de993a1f8a685fc281aa3faa6..f00564af9d8ad7607d1c3d802a4494dadd48d7b1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.155 2000/11/04 23:04:10 hno Exp $
+ * $Id: errorpage.cc,v 1.156 2000/11/13 12:25:11 adrian Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -499,10 +499,10 @@ errorConvert(char token, ErrorState * err)
     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 a1a2f0538a52233e7443ecb277b8d700d4a886d7..ec08aded7ecc21fdddc330ce41b8d2b81fd215b2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.297 2000/11/04 23:04:10 hno Exp $
+ * $Id: ftp.cc,v 1.298 2000/11/13 12:25:12 adrian Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -2462,6 +2462,7 @@ ftpAppendSuccessHeader(FtpStateData * ftpState)
     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 * ftpState)
        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 a73aec9e03a770f0dadc565dc92334e97f9e0963..33cee575ebeba39c4b61f7274b6670aacf1c57cf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.369 2000/11/01 04:03:14 wessels Exp $
+ * $Id: http.cc,v 1.370 2000/11/13 12:25:12 adrian Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -1017,3 +1017,9 @@ httpSendRequestEntryDone(int fd, char *bufnotused, size_t size, int errflag, voi
        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 f076d4fb90ef490a9ff3cf73588f6fa167aeaf54..774c5977a64e7db7d62bc9c87f3e61109e24d8ac 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: internal.cc,v 1.18 2000/03/06 16:23:32 wessels Exp $
+ * $Id: internal.cc,v 1.19 2000/11/13 12:25:12 adrian Exp $
  *
  * DEBUG: section 76    Internal Squid Object handling
  * AUTHOR: Duane, Alex, Henrik
@@ -44,6 +44,7 @@ internalStart(request_t * request, StoreEntry * entry)
 {
     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, StoreEntry * entry)
 #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 e3320cd0fcdb85e91cc6a8771cfc02aa1d478c10..94ef8e8994bfa959ebfa3eecea2fada0c331666d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mime.cc,v 1.94 2000/05/16 07:06:05 wessels Exp $
+ * $Id: mime.cc,v 1.95 2000/11/13 12:25:12 adrian Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -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 78cf656a701b2c469eb32cfd12fb493b7ca44b4a..0e1b24cfcecbe6ed8f1e2905b6c2a6086600894f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.151 2000/10/31 23:48:14 wessels Exp $
+ * $Id: net_db.cc,v 1.152 2000/11/13 12:25:12 adrian Exp $
  *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -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 1605948cf379f3ae6ffa3e2dba3d9a5617659b04..35e939a15f025047a676537ffd47378282b6988b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.386 2000/11/01 04:03:15 wessels Exp $
+ * $Id: protos.h,v 1.387 2000/11/13 12:25:12 adrian Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -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, const ETag * tag2);
 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(const HttpHeaderEntry * e, Packer * p);
 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 HttpReply * rep);
 /* 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 2d972b51167d05b881c6f51fc82583a7080f2811..0254c55834fdbf2d6dfb7e9d095c4eaebd753b67 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.360 2000/11/10 09:04:51 adrian Exp $
+ * $Id: structs.h,v 1.361 2000/11/13 12:25:13 adrian Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -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;
 };
@@ -838,7 +846,7 @@ struct _AccessLogEntry {
        method_t method;
        int code;
        const char *content_type;
-       float version;
+        http_version_t version;
     } http;
     struct {
        icp_opcode opcode;
@@ -880,7 +888,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 +1444,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 b112697b7c88b4847bb9dff3af8a5d00d389abf7..d6660bd028ae6da9506ede40979bd8f0622ff90b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.110 2000/10/17 08:06:05 adrian Exp $
+ * $Id: typedefs.h,v 1.111 2000/11/13 12:25:13 adrian Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -177,6 +177,8 @@ typedef struct _RemovalPurgeWalker RemovalPurgeWalker;
 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 3f4b2432ee4fe624a7990b94590151e37de1d02c..2be95d0cf98e5a1bc9652824c6aa0b820c64e067 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: urn.cc,v 1.60 2000/06/06 19:34:31 hno Exp $
+ * $Id: urn.cc,v 1.61 2000/11/13 12:25:13 adrian Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
@@ -185,6 +185,7 @@ urnHandleReply(void *data, char *buf, ssize_t size)
     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, ssize_t size)
        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");