X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp.c;h=340808997dee3d73570d718573dbd7ddcd89566b;hb=4eeb5ae17702904ec2b5f5628f612526e32f1c58;hp=5430f6e04f0fa881034d5bbccc663aed854b1ecf;hpb=546998faa8f93274c37ee491bbfbb64b7d8857ca;p=pazpar2-moved-to-github.git diff --git a/src/http.c b/src/http.c index 5430f6e..3408089 100644 --- a/src/http.c +++ b/src/http.c @@ -1,5 +1,5 @@ /* - * $Id: http.c,v 1.4 2006-12-21 04:27:17 quinn Exp $ + * $Id: http.c,v 1.9 2007-01-10 11:56:10 adam Exp $ */ #include @@ -15,11 +15,16 @@ #include #include +#if HAVE_CONFIG_H +#include +#endif + +#include + #include #include #include -#include "command.h" #include "util.h" #include "eventl.h" #include "pazpar2.h" @@ -89,10 +94,10 @@ static struct http_buf *http_buf_bybuf(char *b, int len) 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; @@ -372,9 +377,9 @@ struct http_request *http_parse_request(struct http_channel *c, struct http_buf 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); @@ -392,10 +397,10 @@ static struct http_buf *http_serialize_response(struct http_channel *c, 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) @@ -492,8 +497,10 @@ static int http_proxy(struct http_request *rq) 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"); @@ -782,7 +789,7 @@ void http_init(const char *addr) 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)