proxy_util.c revision 26720422632ac831c17501d36b4151598cfe3c90
2d2eda71267231c2526be701fe655db125852c1ffielding/* ====================================================================
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * The Apache Software License, Version 1.1
b99dbaab171d91e1b664397cc40e039d0c087c65fielding * Copyright (c) 2000 The Apache Software Foundation. All rights
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * reserved.
2d2eda71267231c2526be701fe655db125852c1ffielding * Redistribution and use in source and binary forms, with or without
2d2eda71267231c2526be701fe655db125852c1ffielding * modification, are permitted provided that the following conditions
2d2eda71267231c2526be701fe655db125852c1ffielding * 1. Redistributions of source code must retain the above copyright
2d2eda71267231c2526be701fe655db125852c1ffielding * notice, this list of conditions and the following disclaimer.
2d2eda71267231c2526be701fe655db125852c1ffielding * 2. Redistributions in binary form must reproduce the above copyright
2d2eda71267231c2526be701fe655db125852c1ffielding * notice, this list of conditions and the following disclaimer in
2d2eda71267231c2526be701fe655db125852c1ffielding * the documentation and/or other materials provided with the
2d2eda71267231c2526be701fe655db125852c1ffielding * distribution.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * 3. The end-user documentation included with the redistribution,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * if any, must include the following acknowledgment:
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * "This product includes software developed by the
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * Apache Software Foundation (http://www.apache.org/)."
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * Alternately, this acknowledgment may appear in the software itself,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * if and wherever such third-party acknowledgments normally appear.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * 4. The names "Apache" and "Apache Software Foundation" must
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * not be used to endorse or promote products derived from this
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * software without prior written permission. For written
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * permission, please contact apache@apache.org.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * 5. Products derived from this software may not be called "Apache",
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * nor may "Apache" appear in their name, without prior written
64185f9824e42f21ca7b9ae6c004484215c031a7rbb * permission of the Apache Software Foundation.
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
2d2eda71267231c2526be701fe655db125852c1ffielding * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * SUCH DAMAGE.
2d2eda71267231c2526be701fe655db125852c1ffielding * ====================================================================
2d2eda71267231c2526be701fe655db125852c1ffielding * This software consists of voluntary contributions made by many
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * individuals on behalf of the Apache Software Foundation. For more
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * information on the Apache Software Foundation, please see
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * Portions of this software are based upon public domain software
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * originally written at the National Center for Supercomputing Applications,
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * University of Illinois, Urbana-Champaign.
2d2eda71267231c2526be701fe655db125852c1ffielding/* Utility routines for Apache proxy */
c9a95767fbf0f5fb0976a06b97a256033925e433rbbstatic int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r);
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fieldingstatic int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
2d2eda71267231c2526be701fe655db125852c1ffieldingstatic int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
2d2eda71267231c2526be701fe655db125852c1ffieldingstatic int proxy_match_word(struct dirconn_entry *This, request_rec *r);
2d2eda71267231c2526be701fe655db125852c1ffieldingstatic struct per_thread_data *get_per_thread_data(void);
2d2eda71267231c2526be701fe655db125852c1ffielding/* already called in the knowledge that the characters are hex digits */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbint ap_proxy_hex2c(const char *x)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#else /*CHARSET_EBCDIC*/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb return (1 == sscanf(x, "%2x", &i)) ? os_toebcdic[i&0xFF] : 0;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe#endif /*CHARSET_EBCDIC*/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb x[0] = '%';
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (i >= 10)
2d2eda71267231c2526be701fe655db125852c1ffielding if (i >= 10)
2d2eda71267231c2526be701fe655db125852c1ffielding#else /*CHARSET_EBCDIC*/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb x[0] = '%';
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein#endif /*CHARSET_EBCDIC*/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * canonicalise a URL-encoded string
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * Convert a URL-encoded string to canonical form.
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein * It decodes characters which need not be encoded,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * and encodes those which must be encoded, and does not touch
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * those which must not be touched.
61fd0cab072a05b855cbef9c585702401ac5ae29rbbchar *ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int i, j, ch;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe char *allowed; /* characters which should not be encoded */
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein char *reserved; /* characters which much not be en/de-coded */
c9a95767fbf0f5fb0976a06b97a256033925e433rbb/* N.B. in addition to :@&=, this allows ';' in an http path
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * and '?' in an ftp path -- this may be revised
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * Also, it makes a '+' character in a search string reserved, as
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * it may be form-encoded. (Although RFC 1738 doesn't allow this -
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * it only permits ; / ? : @ = & as reserved chars.)
c9a95767fbf0f5fb0976a06b97a256033925e433rbb else if (t == enc_search)
c9a95767fbf0f5fb0976a06b97a256033925e433rbb else if (t == enc_user)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb else if (t == enc_fpath)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb else /* if (t == enc_parm) */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb else if (t == enc_search)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb for (i = 0, j = 0; i < len; i++, j++) {
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* always handle '/' first */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* decode it if not already done */
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein if (!ap_isxdigit(x[i + 1]) || !ap_isxdigit(x[i + 2]))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (ch != 0 && strchr(reserved, ch)) { /* keep it encoded */
2d2eda71267231c2526be701fe655db125852c1ffielding/* recode it, if necessary */
2d2eda71267231c2526be701fe655db125852c1ffielding y[j] = '\0';
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Parses network-location.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * urlp on input the URL; on output the path, after the leading /
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * user NULL if no user/password permitted
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * password holder for password
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * host holder for host
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * port port number; only set if one is supplied.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Returns an error string.
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb return "Malformed URL";
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar /* find _last_ '@' since it might occur in user/password part */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar/* find password */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar password = ap_proxy_canonenc(p, strp + 1, strlen(strp + 1), enc_user, 1);
a19698aebe10b9d41574e4a73794ba7d4cecd78btrawick return "Bad %-escape in URL (password)";
3d96ee83babeec32482c9082c9426340cee8c44dwrowe user = ap_proxy_canonenc(p, user, strlen(user), enc_user, 1);
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar return "Bad %-escape in URL (username)";
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar /* if (i == 0) the no port was given; keep default */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar return "Bad port number in URL";
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar } else if (i > 0) {
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar return "Port number in URL > 65535";
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar ap_str_tolower(host); /* DNS names are case-insensitive */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar return "Missing host in URL";
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar/* check hostname syntax */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar /* must be an IP address */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#if defined(WIN32) || defined(NETWARE) || defined(TPF) || defined(BEOS)
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar if (host[i] == '\0' && (ap_inet_addr(host) == -1 || inet_network(host) == -1))
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar return "Bad IP address in URL";
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar/* if (strchr(host,'.') == NULL && domain != NULL)
2d2eda71267231c2526be701fe655db125852c1ffielding host = pstrcat(p, host, domain, NULL);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * If the date is a valid RFC 850 date or asctime() date, then it
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * is converted to the RFC 1123 format, otherwise it is not modified.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * This routine is not very fast at doing conversions, as it uses
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * sscanf and sprintf. However, if the date is already correctly
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * formatted, then it exits very quickly.
61fd0cab072a05b855cbef9c585702401ac5ae29rbbconst char *
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* check for RFC 850 date */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb *q = '\0';
61fd0cab072a05b855cbef9c585702401ac5ae29rbb return x; /* not a valid date */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (q[4] != '-' || q[8] != '-' || q[11] != ' ' || q[14] != ':' ||
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (sscanf(q + 2, "%u-%3s-%u %u:%u:%u %3s", &mday, month, &year,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* check for acstime() date */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (x[3] != ' ' || x[7] != ' ' || x[10] != ' ' || x[13] != ':' ||
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (sscanf(x, "%3s %3s %u %u:%u:%u %u", week, month, &mday, &hour,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* check date */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_snprintf(q, 30, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", ap_day_snames[wk],
2d2eda71267231c2526be701fe655db125852c1ffielding/* NOTE: This routine is taken from http_protocol::getline()
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * because the old code found in the proxy module was too
2d2eda71267231c2526be701fe655db125852c1ffielding * difficult to understand and maintain.
d839a9822ee53ce00da24c15f2d9fe054233d342gstein/* Get a line of protocol input, including any continuation lines
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * caused by MIME folding (or broken clients) if fold != 0, and place it
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * in the buffer s, of size n bytes, without the ending newline.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Returns -1 on error, or the length of s.
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * Note: Because bgets uses 1 char for newline and 1 char for NUL,
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * the most we can get is (n - 2) actual characters if it
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * was ended by a newline, or (n - 1) characters if the line
2d2eda71267231c2526be701fe655db125852c1ffielding * length exceeded (n - 1). So, if the result == (n - 1),
2d2eda71267231c2526be701fe655db125852c1ffielding * then the actual input line exceeded the buffer length,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * and it would be a good idea for the caller to puke 400 or 414.
61fd0cab072a05b855cbef9c585702401ac5ae29rbbstatic int proxy_getline(char *s, int n, BUFF *in, int fold)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb retval = ap_bgets(pos, n, in); /* retval == -1 if error, 0 if EOF */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* retval is the number of characters read, not including NUL */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (*pos == '\n') { /* Did we get a full line of input? */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb return total; /* if not, input line exceeded buffer size */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Continue appending if line folding is desired and
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * the last line was not empty and we have room in the buffer and
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * the next line begins with a continuation character.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Reads headers from a buffer and returns an array of headers.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Returns NULL on file error
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * This routine tries to deal with too long lines and continuation lines.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * @@@: XXX: FIXME: currently the headers are passed thru un-merged.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Is that okay, or should they be collapsed where possible?
2d2eda71267231c2526be701fe655db125852c1ffieldingapr_table_t *ap_proxy_read_headers(request_rec *r, char *buffer, int size, BUFF *f)
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * Read header lines until we get the empty separator line, a read error,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * the connection closes (EOF), or we timeout.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (!(value = strchr(buffer, ':'))) { /* Find the colon separator */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Buggy MS IIS servers sometimes return invalid headers
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * (an extra "HTTP/1.0 200, OK" line sprinkled in between
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * the usual MIME headers). Try to deal with it in a sensible
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * way, but log the fact.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * XXX: The mask check is buggy if we ever see an HTTP/1.10 */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Nope, it wasn't even an extra HTTP header. Give up. */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, r->server,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb "proxy: Ignoring duplicate HTTP header "
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* XXX: RFC2068 defines only SP and HT as whitespace, this test is
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * wrong... and so are many others probably.
3d96ee83babeec32482c9082c9426340cee8c44dwrowe /* should strip trailing whitespace as well */
2d2eda71267231c2526be701fe655db125852c1ffielding for (end = &value[strlen(value)-1]; end > value && apr_isspace(*end); --end)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* the header was too long; at the least we should skip extra data */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb while ((len = proxy_getline(field, MAX_STRING_LEN, f, 1))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* soak up the extra data */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb if (len == 0) /* time to exit the larger loop as well */
2d2eda71267231c2526be701fe655db125852c1ffieldinglong int ap_proxy_send_fb(proxy_completion *completion, apr_socket_t *f, request_rec *r, ap_cache_el *c)
2d2eda71267231c2526be701fe655db125852c1ffielding register int n, o;
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar int alternate_timeouts = 1; /* 1 if we alternate between soft & hard timeouts */
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding /* The cache copy is ASCII, not EBCDIC, even for text/html) */
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding ap_bsetflag(c->fp, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 0);
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding ap_bsetflag(con->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 0);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Since we are reading from one buffer and writing to another,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * it is unsafe to do a soft_timeout here, at least until the proxy
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * has its own timeout handler which can set both buffers to EOUT.
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein /* works fine under win32, so leave it */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* CHECKME! Since hard_timeout won't work in unix on sends with partial
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * cache completion, we have to alternate between hard_timeout
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * for reads, and soft_timeout for send. This is because we need
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * to get a return from ap_bwrite to be able to continue caching.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * BUT, if we *can't* continue anyway, just use hard_timeout.
42ce672c516baf6e4eaed18ccc1647de2d456d8edougm * (Also, if no cache file is written, use hard timeouts)
42ce672c516baf6e4eaed18ccc1647de2d456d8edougm /* Loop and ap_bread() while we can successfully read and write,
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * or (after the client aborted) while we can successfully
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * read and finish the configured cache_completion.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /* Read block from server */
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding if (c != NULL) {
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb else if(cntr == 0) break;
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb /* Write to cache first. */
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb /*@@@ XXX FIXME: Assuming that writing the cache file won't time out?!!? */
8b7047e519340545e6807c9749576a40a76b6d3frbb if (cachefp && apr_write(cachefp, &buf[0], &wrote_to_cache) != APR_SUCCESS) {
6d00a43be9ab145c89e8cc22bad59e3aa746f761jwoolley "proxy: error writing to cache");
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb /* Write the block to the client, detect aborted transfers */
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb if (apr_send(con->client_socket, &buf[o], &cntr) != APR_SUCCESS) {
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb /* when a send failure occurs, we need to decide
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * whether to continue loading and caching the
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * document, or to abort the whole thing
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb (completion->content_length * completion->cache_completion < total_bytes_rcvd);
c9a95767fbf0f5fb0976a06b97a256033925e433rbb } /* while client alive and more data to send */
c9a95767fbf0f5fb0976a06b97a256033925e433rbb } /* loop and ap_bread while "ok" */
c9a95767fbf0f5fb0976a06b97a256033925e433rbb/* Remove this stuff, because flushing a socket doesn't make a lot of sense
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * currently.
c9a95767fbf0f5fb0976a06b97a256033925e433rbb if (!con->aborted)
c9a95767fbf0f5fb0976a06b97a256033925e433rbb ap_bflush(con->client);
2d2eda71267231c2526be701fe655db125852c1ffielding * Sends response line and headers. Uses the client fd and the
2d2eda71267231c2526be701fe655db125852c1ffielding * headers_out array from the passed request_rec to talk to the client
int len, i;
if (p != NULL) {
i = p - list;
while (apr_isspace(*p));
list = p;
int ap_proxy_hex2sec(const char *x)
int i, ch;
ch = x[i];
void ap_proxy_sec2hex(int t, char *y)
int i, ch;
ap_cache_el_finalize((*c));
*c = NULL;
return statuscode;
return NULL;
return r->hostname;
return NULL;
url = apr_pstrdup(r->pool, &url[1]); /* make it point to "//", which is what proxy_canon_netloc expects */
int i, quads;
long bits;
char *tmp;
char *tmp;
++addr;
--quads;
/* "IP Address should be given in dotted-quad form, optionally followed by a netmask (e.g., 192.168.111.0/24)"; */
char **ip_listptr;
const char *found;
#if DEBUGGING
#if DEBUGGING
#if DEBUGGING
#if DEBUGGING
#if DEBUGGING
--d_len;
--h_len;
int h2_len;
int h1_len;
unsigned long *ip_list;
if (*ip_list == ? ? ? ? ? ? ? ? ? ? ? ? ?)
--h2_len;
--h1_len;
return rv;
/* (from proxy_http.c and proxy_ftp.c) */
if (!r->assbackwards)
return len;
#if defined WIN32
switch (reason) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_DETACH:
if (memptr) {
return TRUE;
#if defined(WIN32)
return &sptd;
return NULL;
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
return OK;
if((r->status != HTTP_OK && r->status != HTTP_MOVED_PERMANENTLY && r->status != HTTP_NOT_MODIFIED) ||
r->header_only ||
if(!h) return DECLINED;
return DECLINED;