return mb;
}
+#if DEAD_CODE
MemBuf *
-httpPackedReply(HttpVersion ver, http_status status, const char *ctype,
- int64_t clen, time_t lmt, time_t expires)
+httpPackedReply(http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires)
{
HttpReply *rep = new HttpReply;
- rep->setHeaders(ver, status, ctype, NULL, clen, lmt, expires);
+ rep->setHeaders(status, ctype, NULL, clen, lmt, expires);
MemBuf *mb = rep->pack();
delete rep;
return mb;
}
+#endif
HttpReply *
-HttpReply::make304 () const
+HttpReply::make304() const
{
static const http_hdr_type ImsEntries[] = {HDR_DATE, HDR_CONTENT_TYPE, HDR_EXPIRES, HDR_LAST_MODIFIED, /* eof */ HDR_OTHER};
/* rv->content_range */
/* rv->keep_alive */
HttpVersion ver(1,0);
- httpStatusLineSet(&rv->sline, ver,
- HTTP_NOT_MODIFIED, "");
+ httpStatusLineSet(&rv->sline, ver, HTTP_NOT_MODIFIED, "");
for (t = 0; ImsEntries[t] != HDR_OTHER; ++t)
if ((e = header.findEntry(ImsEntries[t])))
}
void
-HttpReply::setHeaders(HttpVersion ver, http_status status, const char *reason,
+HttpReply::setHeaders(http_status status, const char *reason,
const char *ctype, int64_t clen, time_t lmt, time_t expiresTime)
{
HttpHeader *hdr;
+ HttpVersion ver(1,0);
httpStatusLineSet(&sline, ver, status, reason);
hdr = &header;
hdr->putStr(HDR_SERVER, visible_appname_string);
extern void httpReplyInitModule(void);
+#if DEAD_CODE
/** do everything in one call: init, set, pack, clean, return MemBuf */
extern MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires);
+#endif
/* Sync changes here with HttpReply.cc */
void updateOnNotModified(HttpReply const *other);
/** set commonly used info with one call */
- void setHeaders(HttpVersion ver, http_status status,
+ void setHeaders(http_status status,
const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires);
/** \return a ready to use mem buffer with a packed reply */
entry->buffer();
{
- HttpVersion version(1,0);
HttpReply *rep = new HttpReply;
- rep->setHeaders(version,
- HTTP_OK,
- NULL,
- "text/plain",
- -1, /* C-Len */
- squid_curtime, /* LMT */
- squid_curtime);
+ rep->setHeaders(HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime);
entry->replaceHttpReply(rep);
}
triggerInitialStoreRead();
HttpReply *rep = new HttpReply;
-
- HttpVersion version(1,0);
-
- rep->setHeaders(version, purgeStatus, NULL, NULL, 0, 0, -1);
-
+ rep->setHeaders(purgeStatus, NULL, NULL, 0, 0, -1);
http->storeEntry()->replaceHttpReply(rep);
-
http->storeEntry()->complete();
}
http->storeEntry()->releaseRequest();
http->storeEntry()->buffer();
HttpReply *rep = new HttpReply;
- HttpVersion version(1,0);
- rep->setHeaders(version, HTTP_OK, NULL, "text/plain",
- http->request->prefixLen(), 0, squid_curtime);
+ rep->setHeaders(HTTP_OK, NULL, "text/plain", http->request->prefixLen(), 0, squid_curtime);
http->storeEntry()->replaceHttpReply(rep);
http->request->swapOut(http->storeEntry());
http->storeEntry()->complete();
PROF_stop(httpRequestFree);
}
-/* Create a request and kick it off */
-/*
+/**
+ * Create a request and kick it off
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ *
* TODO: Pass in the buffers to be used in the inital Read request, as they are
* determined by the user
*/
-int /* returns nonzero on failure */
+int
clientBeginRequest(const HttpRequestMethod& method, char const *url, CSCB * streamcallback,
CSD * streamdetach, ClientStreamData streamdata, HttpHeader const *header,
char *tailbuf, size_t taillen)
{
size_t url_sz;
- HttpVersion http_ver (1, 0);
ClientHttpRequest *http = new ClientHttpRequest(NULL);
HttpRequest *request;
StoreIOBuffer tempBuffer;
}
/*
- * now update the headers in request with our supplied headers. urLParse
+ * now update the headers in request with our supplied headers. urlParse
* should return a blank header set, but we use Update to be sure of
* correctness.
*/
request->my_addr.SetPort(0);
+ /* RFC 2616 says 'upgrade' to our 1.0 regardless of what the client is */
+ HttpVersion http_ver(1,0);
request->http_ver = http_ver;
http->request = HTTPMSGLOCK(request);
HttpReply *rep = new HttpReply;
const char *name = errorPageName(page_id);
/* no LMT for error pages; error pages expire immediately */
- HttpVersion version(1, 0);
if (strchr(name, ':')) {
/* Redirection */
- rep->setHeaders(version, HTTP_MOVED_TEMPORARILY, NULL, "text/html", 0, 0, -1);
+ rep->setHeaders(HTTP_MOVED_TEMPORARILY, NULL, "text/html", 0, 0, -1);
if (request) {
MemBuf redirect_location;
httpHeaderPutStrf(&rep->header, HDR_X_SQUID_ERROR, "%d %s", httpStatus, "Access Denied");
} else {
MemBuf *content = BuildContent();
- rep->setHeaders(version, httpStatus, NULL, "text/html", content->contentSize(), 0, -1);
+ rep->setHeaders(httpStatus, NULL, "text/html", content->contentSize(), 0, -1);
/*
* include some information for downstream caches. Implicit
* replaceable content. This isn't quite sufficient. xerrno is not
/* set standard stuff */
- HttpVersion version(1, 0);
if (0 == getCurrentOffset()) {
/* Full reply */
- reply->setHeaders(version, HTTP_OK, "Gatewaying",
- mime_type, theSize, mdtm, -2);
+ reply->setHeaders(HTTP_OK, "Gatewaying", mime_type, theSize, mdtm, -2);
} else if (theSize < getCurrentOffset()) {
/*
* DPW 2007-05-04
" current offset=" << getCurrentOffset() <<
", but theSize=" << theSize <<
". assuming full content response");
- reply->setHeaders(version, HTTP_OK, "Gatewaying",
- mime_type, theSize, mdtm, -2);
+ reply->setHeaders(HTTP_OK, "Gatewaying", mime_type, theSize, mdtm, -2);
} else {
/* Partial reply */
HttpHdrRangeSpec range_spec;
range_spec.offset = getCurrentOffset();
range_spec.length = theSize - getCurrentOffset();
- reply->setHeaders(version, HTTP_PARTIAL_CONTENT, "Gatewaying",
- mime_type, theSize - getCurrentOffset(), mdtm, -2);
+ reply->setHeaders(HTTP_PARTIAL_CONTENT, "Gatewaying", mime_type, theSize - getCurrentOffset(), mdtm, -2);
httpHeaderAddContRange(&reply->header, range_spec, theSize);
}
HttpReply *reply = new HttpReply;
entry->buffer();
- HttpVersion version(1, 0);
- reply->setHeaders(version, HTTP_OK, "Gatewaying", mime_type, -1, -1, -2);
+ reply->setHeaders(HTTP_OK, "Gatewaying", mime_type, -1, -1, -2);
if (mime_enc)
reply->header.putStr(HDR_CONTENT_ENCODING, mime_enc);
if (!parsed && readBuf->contentSize() > 5 && strncmp(readBuf->content(), "HTTP/", 5) != 0 && strncmp(readBuf->content(), "ICY", 3) != 0) {
MemBuf *mb;
HttpReply *tmprep = new HttpReply;
- tmprep->sline.version = HttpVersion(1, 0);
- tmprep->sline.status = HTTP_OK;
- tmprep->header.putTime(HDR_DATE, squid_curtime);
+ tmprep->setHeaders(HTTP_OK, "Gatewaying", NULL, -1, -1, -1);
tmprep->header.putExt("X-Transformed-From", "HTTP/0.9");
mb = tmprep->pack();
newrep->parse(mb, eof, &error);
if (!parsed && error > 0) { // unrecoverable parsing error
debugs(11, 3, "processReplyHeader: Non-HTTP-compliant header: '" << readBuf->content() << "'");
flags.headers_parsed = 1;
- newrep->sline.version = HttpVersion(1, 0);
+ newrep->sline.version = HttpVersion(1,0);
newrep->sline.status = error;
HttpReply *vrep = setVirginReply(newrep);
entry->replaceHttpReply(vrep);
http_state_flags stateFlags)
{
const int offset = mb->size;
- HttpVersion httpver(1, 0);
+ HttpVersion httpver(1,0);
mb->Printf("%s %s HTTP/%d.%d\r\n",
RequestMethodStr(aRequest->method),
aRequest->urlpath.size() ? aRequest->urlpath.termedBuf() : "/",
struct in_addr line_addr;
s->buffer();
- HttpVersion version(1, 0);
- reply->setHeaders(version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2);
+ reply->setHeaders(HTTP_OK, "OK", NULL, -1, squid_curtime, -2);
s->replaceHttpReply(reply);
rec_sz = 0;
rec_sz += 1 + sizeof(struct in_addr);
memFree(buf, MEM_4K_BUF);
#else
- HttpVersion version(1,0);
- reply->setHeaders(version, HTTP_BAD_REQUEST, "Bad Request",
- NULL, -1, squid_curtime, -2);
+ reply->setHeaders(HTTP_BAD_REQUEST, "Bad Request", NULL, -1, squid_curtime, -2);
s->replaceHttpReply(reply);
storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n");
#endif
const char *msgbuf = "This cache does not support Cache Digests.\n";
#endif
- HttpVersion version(1, 0);
HttpReply *reply = new HttpReply;
- reply->setHeaders(version,
- HTTP_NOT_FOUND,
- "Not Found",
- "text/plain",
- strlen(msgbuf),
- squid_curtime,
- -2);
+ reply->setHeaders(HTTP_NOT_FOUND, "Not Found", "text/plain", strlen(msgbuf), squid_curtime, -2);
entry->replaceHttpReply(reply);
entry->append(msgbuf, strlen(msgbuf));
entry->complete();
HttpReply *reply = new HttpReply;
- HttpVersion version(1, 0);
-
- reply->setHeaders(version, HTTP_OK, NULL,
- mimeGetContentType(icon), sb.st_size, sb.st_mtime, -1);
+ reply->setHeaders(HTTP_OK, NULL, mimeGetContentType(icon), sb.st_size, sb.st_mtime, -1);
reply->cache_control = httpHdrCcCreate();
#if PEER_MULTICAST_SIBLINGS
if (p->type == PEER_MULTICAST && p->options.mcast_siblings &&
(request->flags.nocache || request->flags.refresh || request->flags.loopdetect || request->flags.need_validation))
- debugs(15, 2, "peerAllowedToUse(" << p->name << ", " << request->host << ") : multicast-siblings optimization match");
+ debugs(15, 2, "peerAllowedToUse(" << p->name << ", " << request->GetHost() << ") : multicast-siblings optimization match");
#endif
if (request->flags.nocache)
return 0;
/* Create "vary" base object */
String vary;
StoreEntry *pe = storeCreateEntry(mem_obj->url, mem_obj->log_url, request->flags, request->method);
- HttpVersion version(1, 0);
/* We are allowed to do this typecast */
HttpReply *rep = new HttpReply;
- rep->setHeaders(version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000);
+ rep->setHeaders(HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000);
vary = mem_obj->getReply()->header.getList(HDR_VARY);
if (vary.size()) {
e->setPublicKey();
/* fake reply */
HttpReply *rep = new HttpReply;
- HttpVersion version(1, 0);
- rep->setHeaders(version, HTTP_OK, "Cache Digest OK",
- "application/cache-digest", store_digest->mask_size + sizeof(sd_state.cblock),
- squid_curtime, squid_curtime + Config.digest.rewrite_period);
+ rep->setHeaders(HTTP_OK, "Cache Digest OK",
+ "application/cache-digest", (store_digest->mask_size + sizeof(sd_state.cblock)),
+ squid_curtime, (squid_curtime + Config.digest.rewrite_period) );
debugs(71, 3, "storeDigestRewrite: entry expires on " << rep->expires <<
" (" << std::showpos << (int) (rep->expires - squid_curtime) << ")");
e->buffer();
}
void
-HttpReply::setHeaders(HttpVersion ver, http_status status, const char *reason,
+HttpReply::setHeaders(http_status status, const char *reason,
const char *ctype, int64_t clen, time_t lmt, time_t expires)
{
fatal ("Not implemented");
request_flags flags;
flags.cachable = 1;
StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET);
- HttpVersion version(1, 0);
HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
- rep->setHeaders(version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);
+ rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);
pe->setPublicKey();
request_flags flags;
flags.cachable = 1;
StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET);
- HttpVersion version(1, 0);
/* We are allowed to do this typecast */
HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
- rep->setHeaders(version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);
+ rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);
pe->setPublicKey();
request_flags flags;
flags.cachable = 1;
StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET);
- HttpVersion version(1, 0);
HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
- rep->setHeaders(version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);
+ rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);
pe->setPublicKey();
debugs(52, 3, "urnHandleReply: Called with size=" << (unsigned int)result.length << ".");
- /* Can't be lower because of the goto's */
- HttpVersion version(1, 0);
-
if (EBIT_TEST(urlres_e->flags, ENTRY_ABORTED) || result.length == 0 || result.flags.error < 0) {
urnHandleReplyError(urnState, urlres_e);
return;
"</ADDRESS>\n",
APP_FULLNAME, getMyHostname());
rep = new HttpReply;
- rep->setHeaders(version, HTTP_MOVED_TEMPORARILY, NULL,
- "text/html", mb->contentSize(), 0, squid_curtime);
+ rep->setHeaders(HTTP_MOVED_TEMPORARILY, NULL, "text/html", mb->contentSize(), 0, squid_curtime);
if (urnState->flags.force_menu) {
debugs(51, 3, "urnHandleReply: forcing menu");
{
HttpReply *reply = new HttpReply;
sentry->buffer();
- HttpVersion version(1, 0);
- reply->setHeaders(version, HTTP_OK, "Gatewaying", "text/plain", -1, -1, -2);
+ reply->setHeaders(HTTP_OK, "Gatewaying", "text/plain", -1, -1, -2);
sentry->replaceHttpReply(reply);
}