apr_array_header_t *proxies = conf->proxies;
struct proxy_remote *ents = (struct proxy_remote *) proxies->elts;
int i, rc;
- ap_cache_el *cr = NULL;
int direct_connect = 0;
const char *maxfwd_str;
const char *pragma, *auth, *imstr;
"Request for %s, pragma=%s, auth=%s, imstr=%s", url,
pragma, auth, imstr);
- /* can this request be cached at all? */
- if (r->method_number == M_GET && strlen(url) < 1024 &&
- !ap_proxy_liststr(pragma, "no-cache") && auth == NULL)
- {
- if(ap_cache_seek(conf->cache, url, &cr) == APR_SUCCESS)
- {
- int has_m = 0;
- /* now we need to check if the last modified date is write if */
-
- if(imstr)
- {
- time_t ims = (time_t)ap_parseHTTPdate(ap_proxy_date_canon(r->pool, imstr));
- if(ims == BAD_DATE)
- apr_table_unset(r->headers_in, "If-Modified-Since");
- else
- {
- /* ok we were asked to check, so let's do that */
- if(ap_cache_el_header(cr, "Last-Modified",
- (char **)&imstr) == APR_SUCCESS)
- {
- time_t lm =
- ap_parseHTTPdate(ap_proxy_date_canon(r->pool, imstr)); if(lm != BAD_DATE)
- {
- if(ims < lm)
- apr_table_set(r->headers_in,
- "If-Modified-Since", imstr);
- else
- {
-
- has_m = 1;
- }
- }
- }
- }
- }
- return has_m ? HTTP_NOT_MODIFIED : ap_proxy_cache_send(r, cr);
- }
- /* if there wasn't an entry in the cache we get here,
- we need to create one */
- ap_cache_create(conf->cache, url, &cr);
- }
-
/* If the host doesn't have a domain name, add one and redirect. */
if (conf->domain != NULL) {
rc = proxy_needsdomain(r, url, conf->domain);
* proxy code.
*/
if (r->method_number == M_CONNECT)
- rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
+ rc = ap_proxy_connect_handler(r, url, ents[i].hostname,
ents[i].port);
/* we only know how to handle communication to a proxy via http */
else if (strcasecmp(ents[i].protocol, "http") == 0)
- rc = ap_proxy_http_handler(r, cr, url, ents[i].hostname,
+ rc = ap_proxy_http_handler(r, url, ents[i].hostname,
ents[i].port);
else
rc = DECLINED;
*/
/* handle the scheme */
if (r->method_number == M_CONNECT)
- return ap_proxy_connect_handler(r, cr, url, NULL, 0);
+ return ap_proxy_connect_handler(r, url, NULL, 0);
if (strcasecmp(scheme, "http") == 0)
- return ap_proxy_http_handler(r, cr, url, NULL, 0);
+ return ap_proxy_http_handler(r, url, NULL, 0);
if (strcasecmp(scheme, "ftp") == 0)
- return ap_proxy_ftp_handler(r, cr, url);
+ return ap_proxy_ftp_handler(r, NULL, url);
else
return HTTP_FORBIDDEN;
}
/* proxy_connect.c */
-int ap_proxy_connect_handler(request_rec *r, ap_cache_el *c, char *url,
+int ap_proxy_connect_handler(request_rec *r, char *url,
const char *proxyhost, int proxyport);
/* proxy_ftp.c */
int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme,
int def_port);
-int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
+int ap_proxy_http_handler(request_rec *r, char *url,
const char *proxyhost, int proxyport);
/* proxy_util.c */
}
-int ap_proxy_connect_handler(request_rec *r, ap_cache_el *c, char *url,
+int ap_proxy_connect_handler(request_rec *r, char *url,
const char *proxyhost, int proxyport)
{
struct in_addr destaddr;
* we return DECLINED so that we can try another proxy. (Or the direct
* route.)
*/
-int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
+int ap_proxy_http_handler(request_rec *r, char *url,
const char *proxyhost, int proxyport)
{
const char *strp;
int destport = 0;
char *destportstr = NULL;
const char *urlptr = NULL;
- char *datestr, *clen;
apr_ssize_t cntr;
apr_file_t *cachefp = NULL;
char *buf;
proxy_server_conf *conf =
(proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
struct noproxy_entry *npent = (struct noproxy_entry *) conf->noproxies->elts;
- struct nocache_entry *ncent = (struct nocache_entry *) conf->nocaches->elts;
int nocache = 0;
memset(&server, '\0', sizeof(server));
else
{
clear_connection(p, resp_hdrs); /* Strip Connection hdrs */
- ap_cache_el_header_merge(c, resp_hdrs);
if (apr_table_get(resp_hdrs, "Content-type")) {
r->content_type = apr_pstrdup(r->pool, apr_table_get(resp_hdrs, "Content-type"));
}
} else {
apr_snprintf(portstr, sizeof portstr, ":%d", i);
}
- ap_cache_el_header_add(c, "Via", (conf->viaopt == via_full)
- ? apr_psprintf(p, "%d.%d %s%s (%s)", major, minor,
- ap_get_server_name(r), portstr, AP_SERVER_BASEVERSION)
- : apr_psprintf(p, "%d.%d %s%s", major, minor,
- ap_get_server_name(r), portstr));
}
}
else {
* HTTP/1.0 requires us to accept 3 types of dates, but only generate
* one type
*/
+
+#if 0
if (ap_cache_el_header(c, "Date", &datestr) == APR_SUCCESS)
ap_cache_el_header_set(c, "Date", ap_proxy_date_canon(p, datestr));
if (ap_cache_el_header(c, "Last-Modified", &datestr) == APR_SUCCESS)
ap_cache_el_header_set(c, "Location", proxy_location_reverse_map(r, datestr));
if (ap_cache_el_header(c, "URI", &datestr) == APR_SUCCESS)
ap_cache_el_header_set(c, "URI", proxy_location_reverse_map(r, datestr));
-
-/* check if NoCache directive on this host */
- if (ap_cache_el_header(c, "Content-Length", &clen) == APR_SUCCESS)
- content_length = atoi(clen ? clen : "-1");
-
- for (i = 0; i < conf->nocaches->nelts; i++) {
- if ((ncent[i].name != NULL && ap_strstr_c(desthost, ncent[i].name) != NULL)
- || destaddr.s_addr == ncent[i].addr.s_addr || ncent[i].name[0] == '*')
- nocache = 1;
- }
-
- if(nocache || !ap_proxy_cache_should_cache(r, resp_hdrs, !backasswards))
- ap_proxy_cache_error(&c);
- else
- ap_cache_el_data(c, &cachefp);
+#endif
/* write status line */
#if 0
if (cachefp && apr_write(cachefp, buffer, &cntr) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"proxy: error writing extra data to cache");
- ap_proxy_cache_error(&c);
}
}
}
apr_close_socket(sock);
- if(c) ap_proxy_cache_update(c);
return OK;
}