-/* $Id: http.c,v 1.39 2007-09-26 08:53:53 adam Exp $
+/* $Id: http.c,v 1.42 2007-10-08 13:19:23 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
struct http_channel_observer_s {
void *data;
- void (*destroy)(void *data, struct http_channel *chan);
+ void *data2;
+ http_channel_destroy_t destroy;
struct http_channel_observer_s *next;
struct http_channel *chan;
};
r->channel = c;
r->headers = 0;
r->payload = 0;
+ r->content_type = "text/xml";
return r;
}
if (!(buf = strchr(buf, ' ')))
{
- yaz_log(YLOG_WARN, "Syntax error in request (1)");
+ yaz_log(YLOG_WARN, "Missing Request-URI in HTTP request");
return 0;
}
buf++;
if (!(p = strchr(buf, ' ')))
{
- yaz_log(YLOG_WARN, "Syntax error in request (2)");
+ yaz_log(YLOG_WARN, "HTTP Request-URI not terminated (too long?)");
return 0;
}
*(p++) = '\0';
{
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)
http_channel_observer_t p = c->observers;
while (p)
{
- p->destroy(p->data, c);
+ p->destroy(p->data, c, p->data2);
p = p->next;
}
}
http_channel_observer_t obs = xmalloc(sizeof(*obs));
obs->chan = c;
obs->data = data;
+ obs->data2 = 0;
obs->destroy= des;
obs->next = c->observers;
c->observers = obs;
return obs->chan;
}
+void http_observer_set_data2(http_channel_observer_t obs, void *data2)
+{
+ obs->data2 = data2;
+}
+
+
/*
* Local variables:
* c-basic-offset: 4