-/* $Id: http.c,v 1.39 2007-09-26 08:53:53 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
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 <stdio.h>
#include <sys/socket.h>
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