/*
- * $Id: http.c,v 1.3 2006-12-21 04:16:25 quinn Exp $
+ * $Id: http.c,v 1.8 2007-01-10 10:04:23 adam Exp $
*/
#include <stdio.h>
#include <errno.h>
#include <assert.h>
+#if HAVE_CONFIG_H
+#include <cconfig.h>
+#endif
+
#include <yaz/yaz-util.h>
#include <yaz/comstack.h>
#include <netdb.h>
-#include "command.h"
#include "util.h"
#include "eventl.h"
#include "pazpar2.h"
while (len)
{
- *p = http_buf_create();
int tocopy = len;
if (tocopy > HTTP_BUF_SIZE)
tocopy = HTTP_BUF_SIZE;
+ *p = http_buf_create();
memcpy((*p)->buf, b, tocopy);
(*p)->len = tocopy;
len -= tocopy;
static struct http_buf *http_serialize_response(struct http_channel *c,
struct http_response *r)
{
- wrbuf_rewind(c->wrbuf);
struct http_header *h;
+ wrbuf_rewind(c->wrbuf);
wrbuf_printf(c->wrbuf, "HTTP/1.1 %s %s\r\n", r->code, r->msg);
for (h = r->headers; h; h = h->next)
wrbuf_printf(c->wrbuf, "%s: %s\r\n", h->name, h->value);
static struct http_buf *http_serialize_request(struct http_request *r)
{
struct http_channel *c = r->channel;
- wrbuf_rewind(c->wrbuf);
struct http_header *h;
struct http_argument *a;
+ wrbuf_rewind(c->wrbuf);
wrbuf_printf(c->wrbuf, "%s %s", r->method, r->path);
if (r->arguments)
void http_send_response(struct http_channel *ch)
{
struct http_response *rs = ch->response;
+ struct http_buf *hb;
+
assert(rs);
- struct http_buf *hb = http_serialize_response(ch, rs);
+ hb = http_serialize_response(ch, rs);
if (!hb)
{
yaz_log(YLOG_WARN, "Failed to serialize HTTP response");
return;
}
hc->response = 0;
- yaz_log(YLOG_LOG, "Request: %s %s%s%s v %s", hc->request->method,
+ yaz_log(YLOG_LOG, "Request: %s %s%s%s", hc->request->method,
hc->request->path,
*hc->request->search ? "?" : "",
- hc->request->search,
- hc->request->http_version);
+ hc->request->search);
if (http_weshouldproxy(hc->request))
http_proxy(hc->request);
else
if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0)
yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl2");
- yaz_log(YLOG_LOG, "New command connection");
+ yaz_log(YLOG_DEBUG, "New command connection");
c = iochan_create(s, http_io, EVENT_INPUT | EVENT_EXCEPT);
ch = http_create();
yaz_log(YLOG_LOG, "HTTP listener is %s", addr);
- bzero(&myaddr, sizeof myaddr);
+ memset(&myaddr, 0, sizeof myaddr);
myaddr.sin_family = AF_INET;
pp = strchr(addr, ':');
if (pp)