-/* $Id: http.c,v 1.26 2007-04-15 00:35:57 quinn Exp $
+/* $Id: http.c,v 1.33 2007-06-04 14:44:22 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
static struct http_channel *http_create(const char *addr);
static void http_destroy(IOCHAN i);
-extern IOCHAN channel_list;
-extern struct parameters global_parameters;
-
// If this is set, we proxy normal HTTP requests
static struct sockaddr_in *proxy_addr = 0;
static char proxy_url[256] = "";
return r;
}
-struct http_request *http_parse_request(struct http_channel *c, struct http_buf **queue,
- int len)
+struct http_request *http_parse_request(struct http_channel *c,
+ struct http_buf **queue,
+ int len)
{
struct http_request *r = nmem_malloc(c->nmem, sizeof(*r));
char *p, *p2;
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)
+ {
+ xmlDoc *doc = xmlParseMemory(r->payload, strlen(r->payload));
+ if (doc)
+ {
+ xmlFreeDoc(doc);
+ }
+ else
+ {
+ yaz_log(YLOG_WARN, "Sending non-wellformed "
+ "response (bug #1162");
+ yaz_log(YLOG_WARN, "payload: %s", r->payload);
+ }
+ }
}
wrbuf_puts(c->wrbuf, "\r\n");
// We will add EVENT_OUTPUT below
p->iochan = iochan_create(sock, proxy_io, EVENT_INPUT);
iochan_setdata(p->iochan, p);
- p->iochan->next = channel_list;
- channel_list = p->iochan;
+ pazpar2_add_channel(p->iochan);
}
// Do _not_ modify Host: header, just checking it's existence
ch->iochan = c;
iochan_setdata(c, ch);
- c->next = channel_list;
- channel_list = c;
+ pazpar2_add_channel(c);
}
/* Create a http-channel listener, syntax [host:]port */
strncpy(hostname, addr, len);
hostname[len] = '\0';
- if (!(he = gethostbyname(hostname)))
- {
+ if (!(he = gethostbyname(hostname))){
yaz_log(YLOG_FATAL, "Unable to resolve '%s'", hostname);
exit(1);
}
abort();
if (bind(l, (struct sockaddr *) &myaddr, sizeof myaddr) < 0)
+ {
yaz_log(YLOG_FATAL|YLOG_ERRNO, "bind");
+ exit(1);
+ }
if (listen(l, SOMAXCONN) < 0)
+ {
yaz_log(YLOG_FATAL|YLOG_ERRNO, "listen");
+ exit(1);
+ }
c = iochan_create(l, http_accept, EVENT_INPUT | EVENT_EXCEPT);
- c->next = channel_list;
- channel_list = c;
+ pazpar2_add_channel(c);
}
void http_set_proxyaddr(char *host, char *base_url)