X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp.c;h=cdf2c26759494b16f562d39d971e4d6fd664b301;hb=90dcde08cb73241173e22e84362c6acf9ee92276;hp=9a142d777f40bab7e01ff7d8136ce5fe4ddc5c16;hpb=56a55ffd1562165febc1a2a66d0c2a95e966d540;p=pazpar2-moved-to-github.git diff --git a/src/http.c b/src/http.c index 9a142d7..cdf2c26 100644 --- a/src/http.c +++ b/src/http.c @@ -1,7 +1,5 @@ -/* $Id: http.c,v 1.41 2007-10-02 12:11:14 adam Exp $ - Copyright (c) 2006-2007, Index Data. - -This file is part of Pazpar2. +/* This file is part of Pazpar2. + Copyright (C) 2006-2008 Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -14,10 +12,10 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Pazpar2; see the file LICENSE. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - */ +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ #include #include @@ -118,17 +116,6 @@ static void http_buf_destroy_queue(struct http_buf *b) } } -#ifdef GAGA -// Calculate length of chain -static int http_buf_len(struct http_buf *b) -{ - int sum = 0; - for (; b; b = b->next) - sum += b->len; - return sum; -} -#endif - static struct http_buf *http_buf_bybuf(char *b, int len) { struct http_buf *res = 0; @@ -293,6 +280,7 @@ struct http_response *http_create_response(struct http_channel *c) r->channel = c; r->headers = 0; r->payload = 0; + r->content_type = "text/xml"; return r; } @@ -604,8 +592,8 @@ static struct http_buf *http_serialize_response(struct http_channel *c, { wrbuf_printf(c->wrbuf, "Content-Length: %d\r\n", r->payload ? (int) strlen(r->payload) : 0); - wrbuf_printf(c->wrbuf, "Content-Type: text/xml\r\n"); - if (1) + wrbuf_printf(c->wrbuf, "Content-Type: %s\r\n", r->content_type); + if (!strcmp(r->content_type, "text/xml")) { xmlDoc *doc = xmlParseMemory(r->payload, strlen(r->payload)); if (doc) @@ -914,25 +902,6 @@ static void http_io(IOCHAN i, int event) } } -#ifdef GAGA -// If this hostname contains our proxy host as a prefix, replace with myurl -static char *sub_hostname(struct http_channel *c, char *buf) -{ - char tmp[1024]; - if (strlen(buf) > 1023) - return buf; - if (strncmp(buf, "http://", 7)) - return buf; - if (!strncmp(buf + 7, proxy_url, strlen(proxy_url))) - { - strcpy(tmp, myurl); - strcat(tmp, buf + strlen(proxy_url) + 7); - return nmem_strdup(c->nmem, tmp); - } - return buf; -} -#endif - // Handles I/O on a client connection to a backend web server (proxy mode) static void proxy_io(IOCHAN pi, int event) { @@ -969,33 +938,6 @@ static void proxy_io(IOCHAN pi, int event) htbuf->buf[res] = '\0'; htbuf->offset = 0; htbuf->len = res; -#ifdef GAGA - if (pc->first_response) // Check if this is a redirect - { - int len; - if ((len = package_check(htbuf->buf))) - { - struct http_response *res = http_parse_response_buf(hc, htbuf->buf, len); - if (res) - { - const char *location = http_lookup_header( - res->header, "Location"); - if (location) - { - // We found a location header. Rewrite it. - struct http_buf *buf; - h->value = sub_hostname(hc, location); - buf = http_serialize_response(hc, res); - yaz_log(YLOG_LOG, "Proxy rewrite"); - http_buf_enqueue(&hc->oqueue, buf); - htbuf->offset = len; - break; - } - } - } - pc->first_response = 0; - } -#endif // Write any remaining payload if (htbuf->len - htbuf->offset > 0) http_buf_enqueue(&hc->oqueue, htbuf);