char *destportstr = NULL;
const char *urlptr = NULL;
const char *datestr, *urlstr;
+ char *content_length;
void *sconf = r->server->module_config;
proxy_server_conf *conf =
* says we should strip these headers:
*/
|| !strcasecmp(reqhdrs_elts[i].key, "Host") /* Already sent */
- ||!strcasecmp(reqhdrs_elts[i].key, "Keep-Alive")
+ || !strcasecmp(reqhdrs_elts[i].key, "Keep-Alive")
|| !strcasecmp(reqhdrs_elts[i].key, "TE")
|| !strcasecmp(reqhdrs_elts[i].key, "Trailer")
|| !strcasecmp(reqhdrs_elts[i].key, "Transfer-Encoding")
/* strip hop-by-hop headers defined by Connection and RFC2616 */
ap_proxy_clear_connection(p, resp_hdrs);
+
+ content_length = ap_table_get(resp_hdrs, "Content-Length");
+ if (content_length != NULL)
+ c->len = strtol(content_length, NULL, 10);
+
/* Now add out bound headers set by other modules */
resp_hdrs = ap_overlay_tables(r->pool, r->err_headers_out, resp_hdrs);
}
long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c, off_t len, int nowrite, int chunked, size_t recv_buffer_size)
{
- int ok;
+ int ok, end_of_chunk;
char *buf;
size_t buf_size;
size_t remaining = 0;
* (after the client aborted) while we can successfully read and finish
* the configured cache_completion.
*/
- for (ok = 1; ok;) {
+ for (end_of_chunk = ok = 1; ok;) {
if (alternate_timeouts)
ap_hard_timeout("proxy recv body from upstream server", r);
n = 0;
/* start of a new chunk */
- if (remaining == 0) {
+ if (end_of_chunk) {
+ end_of_chunk = 0;
/* get the chunk size from the stream */
chunk_start = ap_getline(buf, buf_size, f, 0);
if ((chunk_start <= 0) || ((size_t)chunk_start + 1 >= buf_size) || !ap_isxdigit(*buf)) {
n = ap_bread(f, buf, MIN((int)buf_size, (int)remaining));
if (n > -1) {
remaining -= n;
+ end_of_chunk = (remaining == 0);
}
}
/* soak up trailing CRLF */
- if (0 == remaining) {
+ if (end_of_chunk) {
int ch; /* int because it may hold an EOF */
/*
* For EBCDIC, the proxy has configured the BUFF layer to
n = ap_bread(f, buf, buf_size);
}
else {
- n = ap_bread(f, buf, MIN((int)buf_size,
+ n = ap_bread(f, buf, MIN((int)buf_size,
(int)(len - total_bytes_rcvd)));
}
}
const char *name;
char *next = ap_pstrdup(p, ap_table_get(headers, "Connection"));
+ /* Some proxies (Squid, ICS) use the non-standard "Proxy-Connection" header. */
ap_table_unset(headers, "Proxy-Connection");
- if (!next)
- return;
- while (*next) {
- name = next;
- while (*next && !ap_isspace(*next) && (*next != ','))
- ++next;
- while (*next && (ap_isspace(*next) || (*next == ','))) {
- *next = '\0';
- ++next;
+ if (next != NULL) {
+ while (*next) {
+ name = next;
+ while (*next && !ap_isspace(*next) && (*next != ','))
+ ++next;
+ while (*next && (ap_isspace(*next) || (*next == ','))) {
+ *next = '\0';
+ ++next;
+ }
+ ap_table_unset(headers, name);
}
- ap_table_unset(headers, name);
+ ap_table_unset(headers, "Connection");
}
- ap_table_unset(headers, "Connection");
/* unset hop-by-hop headers defined in RFC2616 13.5.1 */
ap_table_unset(headers,"Keep-Alive");