/*
- * $Id: client.cc,v 1.62 1998/03/31 05:37:36 wessels Exp $
+ * $Id: client.cc,v 1.63 1998/04/02 04:45:03 rousskov Exp $
*
* DEBUG: section 0 WWW Client
* AUTHOR: Harvest Derived
break;
case 'H':
if (strlen(optarg)) {
+ char *t;
strncpy(extra_hdrs, optarg, sizeof(extra_hdrs));
+ while ((t = strstr(extra_hdrs, "\\n")))
+ *t = '\r', *(t+1) = '\n';
}
break;
case 'v':
/*
- * $Id: client_side.cc,v 1.248 1998/04/01 21:23:02 wessels Exp $
+ * $Id: client_side.cc,v 1.249 1998/04/02 04:45:04 rousskov Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
request->imslen = atoi(t + 7);
}
}
- if ((t = mime_get_header(request_hdr, "Pragma"))) {
- if (!strcasecmp(t, "no-cache"))
- EBIT_SET(request->flags, REQ_NOCACHE);
+ if ((t = mime_get_header_field(request_hdr, "Pragma", "no-cache"))) {
+ EBIT_SET(request->flags, REQ_NOCACHE);
}
if (mime_get_header(request_hdr, "Range")) {
EBIT_SET(request->flags, REQ_NOCACHE);
if ((t = mime_get_header(request_hdr, "X-Forwarded-For")))
fvdbCountForw(t);
#endif
- request->max_age = -1;
- if ((t = mime_get_header(request_hdr, "Cache-control"))) {
- if (!strncasecmp(t, "Max-age=", 8))
- request->max_age = atoi(t + 8);
+ if ((t = mime_get_header_field(request_hdr, "Cache-control", "max-age="))) {
+ request->max_age = atoi(t + 8);
+ } else {
+ request->max_age = -1;
+ }
+ if ((t = mime_get_header_field(request_hdr, "Cache-control", "only-if-cached"))) {
+ EBIT_SET(request->flags, REQ_CC_ONLY_IF_CACHED);
}
if (request->method == METHOD_TRACE) {
if ((t = mime_get_header(request_hdr, "Max-Forwards")))
}
/* ok, it is a miss or a "dirty" hit (will contact other servers) */
/* are we allowed to contact other servers? */
- if (r->cache_control && EBIT_TEST(r->cache_control->mask, CC_ONLY_IF_CACHED)) {
+ if (EBIT_TEST(r->flags, REQ_CC_ONLY_IF_CACHED)) {
+ /* future interface: if (r->cache_control && EBIT_TEST(r->cache_control->mask, CC_ONLY_IF_CACHED)) { */
/* nope, bailing out */
clientProcessOnlyIfCachedMiss(http);
return;
REQ_PROXY_KEEPALIVE,
REQ_PROXYING,
REQ_REFRESH,
- REQ_USED_PROXY_AUTH
+ REQ_USED_PROXY_AUTH,
+ REQ_CC_ONLY_IF_CACHED
};
enum {
/*
- * $Id: mime.cc,v 1.58 1998/04/01 00:12:33 wessels Exp $
+ * $Id: mime.cc,v 1.59 1998/04/02 04:45:06 rousskov Exp $
*
* DEBUG: section 25 MIME Parsing
* AUTHOR: Harvest Derived
static void mimeLoadIconFile(const char *icon);
+/* returns a pointer to a field-value of the first matching field-name */
char *
mime_get_header(const char *mime, const char *name)
+{
+ return mime_get_header_field(mime, name, NULL);
+}
+
+/*
+ * returns a pointer to a field-value of the first matching field-name where
+ * field-value matches prefix if any
+ */
+char *
+mime_get_header_field(const char *mime, const char *name, const char *prefix)
{
LOCAL_ARRAY(char, header, GET_HDR_SZ);
const char *p = NULL;
char *q = NULL;
char got = 0;
- int namelen = strlen(name);
+ const int namelen = name ? strlen(name) : 0;
+ const int preflen = prefix ? strlen(prefix) : 0;
int l;
if (!mime || !name)
q++, got = 1;
while (isspace(*q))
q++, got = 1;
+ if (got && prefix) {
+ /* we could process list entries here if we had strcasestr(). */
+ /* make sure we did not match a part of another field-value */
+ got = !strncasecmp(q, prefix, preflen) && !isalpha(q[preflen]);
+ }
if (got) {
debug(25, 5) ("mime_get_header: returning '%s'\n", q);
return q;
extern void memBufReport(MemBuf * mb);
extern char *mime_get_header(const char *mime, const char *header);
+char *mime_get_header_field(const char *mime, const char *name, const char *prefix);
#if OLD_CODE
extern char *mime_headers_end(const char *mime);
#endif