two integers.
Submitted by: Robert Collins <robert.collins@itdomain.com.au>
/*
- * $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
/* 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.
/*
- * $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
}
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();
}
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;
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);
/*
- * $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;
{
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 */
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);
/*
- * $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
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],
/*
- * $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
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",
/*
- * $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
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;
*/
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);
}
{
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)
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" */
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);
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);
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;
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);
}
/*
/*
- * $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
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);
{
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
/*
- * $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
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;
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 */
/*
- * $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
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;
+}
/*
- * $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
{
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")) {
#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",
/*
- * $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
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);
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);
/*
- * $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
netdbBinaryExchange(StoreEntry * s)
{
http_reply *reply = s->mem_obj->reply;
+ http_version_t version;
#if USE_ICMP
netdbEntry *n;
int i;
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;
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
/*
- * $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/
extern void whoisStart(FwdState *);
+/* http.c */
extern int httpCachable(method_t);
extern void httpStart(FwdState *);
extern void httpParseReplyHeaders(const char *, http_reply *);
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);
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 */
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 */
/* 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);
/*
- * $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/
char *buf;
};
+struct _http_version_t {
+ unsigned int major;
+ unsigned int minor;
+};
+
#if SQUID_SNMP
struct _snmp_request_t {
/* 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;
};
method_t method;
int code;
const char *content_type;
- float version;
+ http_version_t version;
} http;
struct {
icp_opcode opcode;
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;
request_flags flags;
HttpHdrCc *cache_control;
HttpHdrRange *range;
- float http_ver;
+ http_version_t http_ver;
time_t ims;
int imslen;
int max_forwards;
/*
- * $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/
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;
/*
- * $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
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)) {
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");