1 /* $Id: http.c,v 1.36 2007-07-03 10:10:14 adam Exp $
2 Copyright (c) 2006-2007, Index Data.
4 This file is part of Pazpar2.
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include <sys/socket.h>
24 #include <sys/types.h>
40 #include <netinet/in.h>
41 #include <arpa/inet.h>
44 #include <yaz/yaz-util.h>
45 #include <yaz/comstack.h>
53 #include "http_command.h"
55 static void proxy_io(IOCHAN i, int event);
56 static struct http_channel *http_create(const char *addr);
57 static void http_destroy(IOCHAN i);
59 // If this is set, we proxy normal HTTP requests
60 static struct sockaddr_in *proxy_addr = 0;
61 static char proxy_url[256] = "";
62 static char myurl[256] = "";
63 static struct http_buf *http_buf_freelist = 0;
64 static struct http_channel *http_channel_freelist = 0;
66 struct http_channel_observer_s {
68 void (*destroy)(void *data, struct http_channel *chan);
69 struct http_channel_observer_s *next;
70 struct http_channel *chan;
73 static struct http_buf *http_buf_create()
77 if (http_buf_freelist)
79 r = http_buf_freelist;
80 http_buf_freelist = http_buf_freelist->next;
83 r = xmalloc(sizeof(struct http_buf));
90 static void http_buf_destroy(struct http_buf *b)
92 b->next = http_buf_freelist;
93 http_buf_freelist = b;
96 static void http_buf_destroy_queue(struct http_buf *b)
108 // Calculate length of chain
109 static int http_buf_len(struct http_buf *b)
112 for (; b; b = b->next)
118 static struct http_buf *http_buf_bybuf(char *b, int len)
120 struct http_buf *res = 0;
121 struct http_buf **p = &res;
126 if (tocopy > HTTP_BUF_SIZE)
127 tocopy = HTTP_BUF_SIZE;
128 *p = http_buf_create();
129 memcpy((*p)->buf, b, tocopy);
138 // Add a (chain of) buffers to the end of an existing queue.
139 static void http_buf_enqueue(struct http_buf **queue, struct http_buf *b)
142 queue = &(*queue)->next;
146 static struct http_buf *http_buf_bywrbuf(WRBUF wrbuf)
148 // Heavens to Betsy (buf)!
149 return http_buf_bybuf(wrbuf_buf(wrbuf), wrbuf_len(wrbuf));
152 // Non-destructively collapse chain of buffers into a string (max *len)
154 static int http_buf_peek(struct http_buf *b, char *buf, int len)
157 while (b && rd < len)
159 int toread = len - rd;
162 memcpy(buf + rd, b->buf + b->offset, toread);
170 // Ddestructively munch up to len from head of queue.
171 static int http_buf_read(struct http_buf **b, char *buf, int len)
174 while ((*b) && rd < len)
176 int toread = len - rd;
177 if (toread > (*b)->len)
179 memcpy(buf + rd, (*b)->buf + (*b)->offset, toread);
181 if (toread < (*b)->len)
184 (*b)->offset += toread;
189 struct http_buf *n = (*b)->next;
190 http_buf_destroy(*b);
198 // Buffers may overlap.
199 static void urldecode(char *i, char *o)
211 sscanf(i, "%2hhx", o);
221 // Warning: Buffers may not overlap
222 void urlencode(const char *i, char *o)
226 if (strchr(" /:", *i))
228 sprintf(o, "%%%.2X", (int) *i);
238 void http_addheader(struct http_response *r, const char *name, const char *value)
240 struct http_channel *c = r->channel;
241 struct http_header *h = nmem_malloc(c->nmem, sizeof *h);
242 h->name = nmem_strdup(c->nmem, name);
243 h->value = nmem_strdup(c->nmem, value);
244 h->next = r->headers;
248 char *http_argbyname(struct http_request *r, char *name)
250 struct http_argument *p;
253 for (p = r->arguments; p; p = p->next)
254 if (!strcmp(p->name, name))
259 char *http_headerbyname(struct http_header *h, char *name)
261 for (; h; h = h->next)
262 if (!strcmp(h->name, name))
267 struct http_response *http_create_response(struct http_channel *c)
269 struct http_response *r = nmem_malloc(c->nmem, sizeof(*r));
270 strcpy(r->code, "200");
278 // Check if buf contains a package (minus payload)
279 static int package_check(const char *buf)
282 while (*buf) // Check if we have a sequence of lines terminated by an empty line
284 char *b = strstr(buf, "\r\n");
289 len += (b - buf) + 2;
297 // Check if we have a request. Return 0 or length
298 // (including trailing CRNL) FIXME: Does not deal gracefully with requests
299 // carrying payload but this is kind of OK since we will reject anything
300 // other than an empty GET
301 static int request_check(struct http_buf *queue)
305 http_buf_peek(queue, tmp, 4096);
306 return package_check(tmp);
309 struct http_response *http_parse_response_buf(struct http_channel *c, const char *buf, int len)
312 struct http_response *r = http_create_response(c);
314 struct http_header **hp = &r->headers;
318 memcpy(tmp, buf, len);
319 for (p = tmp; *p && *p != ' '; p++) // Skip HTTP version
323 for (p2 = p; *p2 && *p2 != ' ' && p2 - p < 3; p2++)
324 r->code[p2 - p] = *p2;
325 if (!(p = strstr(tmp, "\r\n")))
330 if (!(p2 = strstr(p, "\r\n")))
332 if (p == p2) // End of headers
336 struct http_header *h = *hp = nmem_malloc(c->nmem, sizeof(*h));
337 char *value = strchr(p, ':');
341 h->name = nmem_strdup(c->nmem, p);
342 while (isspace(*value))
344 if (value >= p2) // Empty header;
351 h->value = nmem_strdup(c->nmem, value);
360 struct http_request *http_parse_request(struct http_channel *c,
361 struct http_buf **queue,
364 struct http_request *r = nmem_malloc(c->nmem, sizeof(*r));
371 yaz_log(YLOG_WARN, "http_parse_request len > 4096 (%d)", len);
374 if (http_buf_read(queue, buf, len) < len)
376 yaz_log(YLOG_WARN, "http_buf_read < len 4096 (%d)", len);
384 for (p = buf, p2 = r->method; *p && *p != ' ' && p - buf < 19; p++)
388 yaz_log(YLOG_WARN, "Unexpected HTTP method in request");
393 if (!(buf = strchr(buf, ' ')))
395 yaz_log(YLOG_WARN, "Syntax error in request (1)");
399 if (!(p = strchr(buf, ' ')))
401 yaz_log(YLOG_WARN, "Syntax error in request (2)");
405 if ((p2 = strchr(buf, '?'))) // Do we have arguments?
407 r->path = nmem_strdup(c->nmem, buf);
410 r->search = nmem_strdup(c->nmem, p2);
414 struct http_argument *a;
415 char *equal = strchr(p2, '=');
416 char *eoa = strchr(p2, '&');
419 yaz_log(YLOG_WARN, "Expected '=' in argument");
423 eoa = equal + strlen(equal); // last argument
426 a = nmem_malloc(c->nmem, sizeof(struct http_argument));
428 a->name = nmem_strdup(c->nmem, p2);
429 urldecode(a->name, a->name);
430 urldecode(equal, equal);
431 a->value = nmem_strdup(c->nmem, equal);
432 a->next = r->arguments;
439 if (strncmp(buf, "HTTP/", 5))
440 strcpy(r->http_version, "1.0");
444 if (!(p = strstr(buf, "\r\n")))
446 yaz_log(YLOG_WARN, "Did not see \\r\\n (1)");
451 strcpy(r->http_version, buf);
454 strcpy(c->version, r->http_version);
459 if (!(p = strstr(buf, "\r\n")))
461 yaz_log(YLOG_WARN, "Did not see \\r\\n (2)");
468 struct http_header *h = nmem_malloc(c->nmem, sizeof(*h));
469 if (!(p2 = strchr(buf, ':')))
472 h->name = nmem_strdup(c->nmem, buf);
475 if (p2 >= p) // Empty header?
481 h->value = nmem_strdup(c->nmem, p2);
482 h->next = r->headers;
491 static struct http_buf *http_serialize_response(struct http_channel *c,
492 struct http_response *r)
494 struct http_header *h;
496 wrbuf_rewind(c->wrbuf);
497 wrbuf_printf(c->wrbuf, "HTTP/1.1 %s %s\r\n", r->code, r->msg);
498 for (h = r->headers; h; h = h->next)
499 wrbuf_printf(c->wrbuf, "%s: %s\r\n", h->name, h->value);
502 wrbuf_printf(c->wrbuf, "Content-length: %d\r\n", r->payload ?
503 (int) strlen(r->payload) : 0);
504 wrbuf_printf(c->wrbuf, "Content-type: text/xml\r\n");
507 xmlDoc *doc = xmlParseMemory(r->payload, strlen(r->payload));
514 yaz_log(YLOG_WARN, "Sending non-wellformed "
515 "response (bug #1162");
516 yaz_log(YLOG_WARN, "payload: %s", r->payload);
520 wrbuf_puts(c->wrbuf, "\r\n");
523 wrbuf_puts(c->wrbuf, r->payload);
525 return http_buf_bywrbuf(c->wrbuf);
528 // Serialize a HTTP request
529 static struct http_buf *http_serialize_request(struct http_request *r)
531 struct http_channel *c = r->channel;
532 struct http_header *h;
533 struct http_argument *a;
535 wrbuf_rewind(c->wrbuf);
536 wrbuf_printf(c->wrbuf, "%s %s", r->method, r->path);
540 wrbuf_putc(c->wrbuf, '?');
541 for (a = r->arguments; a; a = a->next) {
542 if (a != r->arguments)
543 wrbuf_putc(c->wrbuf, '&');
544 wrbuf_printf(c->wrbuf, "%s=%s", a->name, a->value);
548 wrbuf_printf(c->wrbuf, " HTTP/%s\r\n", r->http_version);
550 for (h = r->headers; h; h = h->next)
551 wrbuf_printf(c->wrbuf, "%s: %s\r\n", h->name, h->value);
553 wrbuf_puts(c->wrbuf, "\r\n");
555 return http_buf_bywrbuf(c->wrbuf);
559 static int http_weshouldproxy(struct http_request *rq)
561 if (proxy_addr && !strstr(rq->path, "search.pz2"))
567 struct http_header * http_header_append(struct http_channel *ch,
568 struct http_header * hp,
572 struct http_header *hpnew = 0;
577 while (hp && hp->next)
580 if(name && strlen(name)&& value && strlen(value)){
581 hpnew = nmem_malloc(ch->nmem, sizeof *hpnew);
582 hpnew->name = nmem_strdup(ch->nmem, name);
583 hpnew->value = nmem_strdup(ch->nmem, value);
597 static int http_proxy(struct http_request *rq)
599 struct http_channel *c = rq->channel;
600 struct http_proxy *p = c->proxy;
601 struct http_header *hp;
602 struct http_buf *requestbuf;
603 char server_via[128] = "";
604 char server_port[16] = "";
605 struct conf_server *ser = global_parameters.server;
607 if (!p) // This is a new connection. Create a proxy channel
614 if (!(pe = getprotobyname("tcp"))) {
617 if ((sock = socket(PF_INET, SOCK_STREAM, pe->p_proto)) < 0)
619 yaz_log(YLOG_WARN|YLOG_ERRNO, "socket");
622 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)
623 &one, sizeof(one)) < 0)
625 if ((flags = fcntl(sock, F_GETFL, 0)) < 0)
626 yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl");
627 if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0)
628 yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl2");
629 if (connect(sock, (struct sockaddr *) proxy_addr,
630 sizeof(*proxy_addr)) < 0)
631 if (errno != EINPROGRESS)
633 yaz_log(YLOG_WARN|YLOG_ERRNO, "Proxy connect");
637 p = xmalloc(sizeof(struct http_proxy));
640 p->first_response = 1;
642 // We will add EVENT_OUTPUT below
643 p->iochan = iochan_create(sock, proxy_io, EVENT_INPUT);
644 iochan_setdata(p->iochan, p);
645 pazpar2_add_channel(p->iochan);
648 // Do _not_ modify Host: header, just checking it's existence
649 for (hp = rq->headers; hp; hp = hp->next)
650 if (!strcmp(hp->name, "Host"))
654 yaz_log(YLOG_WARN, "Failed to find Host header in proxy");
658 // Add new header about paraz2 version, host, remote client address, etc.
661 hp = http_header_append(c, hp,
662 "X-Pazpar2-Version", PACKAGE_VERSION);
663 hp = http_header_append(c, hp,
664 "X-Pazpar2-Server-Host", ser->host);
665 sprintf(server_port, "%d", ser->port);
666 hp = http_header_append(c, hp,
667 "X-Pazpar2-Server-Port", server_port);
668 sprintf(server_via, "1.1 %s:%s (%s/%s)",
669 ser->host, server_port, PACKAGE_NAME, PACKAGE_VERSION);
670 hp = http_header_append(c, hp, "Via" , server_via);
671 hp = http_header_append(c, hp, "X-Forwarded-For", c->addr);
674 requestbuf = http_serialize_request(rq);
675 http_buf_enqueue(&p->oqueue, requestbuf);
676 iochan_setflag(p->iochan, EVENT_OUTPUT);
680 void http_send_response(struct http_channel *ch)
682 struct http_response *rs = ch->response;
686 hb = http_serialize_response(ch, rs);
689 yaz_log(YLOG_WARN, "Failed to serialize HTTP response");
690 http_destroy(ch->iochan);
694 http_buf_enqueue(&ch->oqueue, hb);
695 iochan_setflag(ch->iochan, EVENT_OUTPUT);
696 ch->state = Http_Idle;
700 static void http_io(IOCHAN i, int event)
702 struct http_channel *hc = iochan_getdata(i);
707 struct http_buf *htbuf;
710 htbuf = http_buf_create();
711 res = read(iochan_getfd(i), htbuf->buf, HTTP_BUF_SIZE -1);
712 if (res == -1 && errno == EAGAIN)
714 http_buf_destroy(htbuf);
719 http_buf_destroy(htbuf);
723 htbuf->buf[res] = '\0';
725 http_buf_enqueue(&hc->iqueue, htbuf);
727 if (hc->state == Http_Busy)
729 if ((reqlen = request_check(hc->iqueue)) <= 2)
732 nmem_reset(hc->nmem);
733 if (!(hc->request = http_parse_request(hc, &hc->iqueue, reqlen)))
735 yaz_log(YLOG_WARN, "Failed to parse request");
740 yaz_log(YLOG_LOG, "Request: %s %s%s%s", hc->request->method,
742 *hc->request->search ? "?" : "",
743 hc->request->search);
744 if (http_weshouldproxy(hc->request))
745 http_proxy(hc->request);
748 // Execute our business logic!
749 hc->state = Http_Busy;
754 yaz_log(YLOG_DEBUG, "We think we have more input to read. Forcing event");
755 iochan_setevent(i, EVENT_INPUT);
763 struct http_buf *wb = hc->oqueue;
764 res = write(iochan_getfd(hc->iochan), wb->buf + wb->offset, wb->len);
767 yaz_log(YLOG_WARN|YLOG_ERRNO, "write");
773 hc->oqueue = hc->oqueue->next;
774 http_buf_destroy(wb);
782 if (!strcmp(hc->version, "1.0"))
789 iochan_clearflag(i, EVENT_OUTPUT);
791 iochan_setevent(hc->iochan, EVENT_INPUT);
796 if (!hc->oqueue && hc->proxy && !hc->proxy->iochan)
797 http_destroy(i); // Server closed; we're done
800 yaz_log(YLOG_WARN, "Unexpected event on connection");
806 // If this hostname contains our proxy host as a prefix, replace with myurl
807 static char *sub_hostname(struct http_channel *c, char *buf)
810 if (strlen(buf) > 1023)
812 if (strncmp(buf, "http://", 7))
814 if (!strncmp(buf + 7, proxy_url, strlen(proxy_url)))
817 strcat(tmp, buf + strlen(proxy_url) + 7);
818 return nmem_strdup(c->nmem, tmp);
824 // Handles I/O on a client connection to a backend web server (proxy mode)
825 static void proxy_io(IOCHAN pi, int event)
827 struct http_proxy *pc = iochan_getdata(pi);
828 struct http_channel *hc = pc->channel;
833 struct http_buf *htbuf;
836 htbuf = http_buf_create();
837 res = read(iochan_getfd(pi), htbuf->buf, HTTP_BUF_SIZE -1);
838 if (res == 0 || (res < 0 && errno != EINPROGRESS))
842 yaz_log(YLOG_WARN, "Proxy read came up short");
843 // Close channel and alert client HTTP channel that we're gone
844 http_buf_destroy(htbuf);
845 close(iochan_getfd(pi));
851 http_destroy(hc->iochan);
857 htbuf->buf[res] = '\0';
861 if (pc->first_response) // Check if this is a redirect
864 if ((len = package_check(htbuf->buf)))
866 struct http_response *res = http_parse_response_buf(hc, htbuf->buf, len);
869 struct http_header *h;
870 for (h = res->headers; h; h = h->next)
871 if (!strcmp(h->name, "Location"))
873 // We found a location header. Rewrite it.
874 struct http_buf *buf;
875 h->value = sub_hostname(hc, h->value);
876 buf = http_serialize_response(hc, res);
877 yaz_log(YLOG_LOG, "Proxy rewrite");
878 http_buf_enqueue(&hc->oqueue, buf);
884 pc->first_response = 0;
887 // Write any remaining payload
888 if (htbuf->len - htbuf->offset > 0)
889 http_buf_enqueue(&hc->oqueue, htbuf);
891 iochan_setflag(hc->iochan, EVENT_OUTPUT);
894 if (!(htbuf = pc->oqueue))
896 iochan_clearflag(pi, EVENT_OUTPUT);
899 res = write(iochan_getfd(pi), htbuf->buf + htbuf->offset, htbuf->len);
902 yaz_log(YLOG_WARN|YLOG_ERRNO, "write");
903 http_destroy(hc->iochan);
906 if (res == htbuf->len)
908 struct http_buf *np = htbuf->next;
909 http_buf_destroy(htbuf);
915 htbuf->offset += res;
919 iochan_setflags(pi, EVENT_INPUT); // Turns off output flag
923 yaz_log(YLOG_WARN, "Unexpected event on connection");
924 http_destroy(hc->iochan);
928 static void http_fire_observers(struct http_channel *c);
929 static void http_destroy_observers(struct http_channel *c);
932 static void http_destroy(IOCHAN i)
934 struct http_channel *s = iochan_getdata(i);
938 if (s->proxy->iochan)
940 close(iochan_getfd(s->proxy->iochan));
941 iochan_destroy(s->proxy->iochan);
943 http_buf_destroy_queue(s->proxy->oqueue);
946 http_buf_destroy_queue(s->iqueue);
947 http_buf_destroy_queue(s->oqueue);
948 http_fire_observers(s);
949 http_destroy_observers(s);
950 s->next = http_channel_freelist;
951 http_channel_freelist = s;
952 close(iochan_getfd(i));
956 static struct http_channel *http_create(const char *addr)
958 struct http_channel *r = http_channel_freelist;
962 http_channel_freelist = r->next;
964 wrbuf_rewind(r->wrbuf);
968 r = xmalloc(sizeof(struct http_channel));
969 r->nmem = nmem_create();
970 r->wrbuf = wrbuf_alloc();
974 r->iqueue = r->oqueue = 0;
975 r->state = Http_Idle;
980 yaz_log(YLOG_WARN, "Invalid HTTP forward address");
983 strcpy(r->addr, addr);
989 /* Accept a new command connection */
990 static void http_accept(IOCHAN i, int event)
992 struct sockaddr_in addr;
993 int fd = iochan_getfd(i);
998 struct http_channel *ch;
1001 if ((s = accept(fd, (struct sockaddr *) &addr, &len)) < 0)
1003 yaz_log(YLOG_WARN|YLOG_ERRNO, "accept");
1006 if ((flags = fcntl(s, F_GETFL, 0)) < 0)
1007 yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl");
1008 if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0)
1009 yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl2");
1011 yaz_log(YLOG_DEBUG, "New command connection");
1012 c = iochan_create(s, http_io, EVENT_INPUT | EVENT_EXCEPT);
1014 ch = http_create(inet_ntoa(addr.sin_addr));
1016 iochan_setdata(c, ch);
1018 pazpar2_add_channel(c);
1021 /* Create a http-channel listener, syntax [host:]port */
1022 void http_init(const char *addr)
1027 struct sockaddr_in myaddr;
1032 yaz_log(YLOG_LOG, "HTTP listener %s", addr);
1034 memset(&myaddr, 0, sizeof myaddr);
1035 myaddr.sin_family = AF_INET;
1036 pp = strchr(addr, ':');
1039 int len = pp - addr;
1043 strncpy(hostname, addr, len);
1044 hostname[len] = '\0';
1045 if (!(he = gethostbyname(hostname))){
1046 yaz_log(YLOG_FATAL, "Unable to resolve '%s'", hostname);
1050 memcpy(&myaddr.sin_addr.s_addr, he->h_addr_list[0], he->h_length);
1051 port = atoi(pp + 1);
1053 yaz_log(YLOG_LOG, "HTTP address %s:%d",
1054 "" == he->h_addr_list[0] ? he->h_addr_list[0] : "127.0.0.1" ,
1061 myaddr.sin_addr.s_addr = INADDR_ANY;
1064 myaddr.sin_port = htons(port);
1066 if (!(p = getprotobyname("tcp"))) {
1069 if ((l = socket(PF_INET, SOCK_STREAM, p->p_proto)) < 0)
1070 yaz_log(YLOG_FATAL|YLOG_ERRNO, "socket");
1071 if (setsockopt(l, SOL_SOCKET, SO_REUSEADDR, (char*)
1072 &one, sizeof(one)) < 0)
1075 if (bind(l, (struct sockaddr *) &myaddr, sizeof myaddr) < 0)
1077 yaz_log(YLOG_FATAL|YLOG_ERRNO, "bind");
1080 if (listen(l, SOMAXCONN) < 0)
1082 yaz_log(YLOG_FATAL|YLOG_ERRNO, "listen");
1086 c = iochan_create(l, http_accept, EVENT_INPUT | EVENT_EXCEPT);
1087 pazpar2_add_channel(c);
1090 void http_set_proxyaddr(char *host, char *base_url)
1096 strcpy(myurl, base_url);
1097 strcpy(proxy_url, host);
1098 p = strchr(host, ':');
1099 yaz_log(YLOG_DEBUG, "Proxying for %s", host);
1100 yaz_log(YLOG_LOG, "HTTP backend %s", proxy_url);
1107 if (!(he = gethostbyname(host)))
1109 fprintf(stderr, "Failed to lookup '%s'\n", host);
1112 proxy_addr = xmalloc(sizeof(struct sockaddr_in));
1113 proxy_addr->sin_family = he->h_addrtype;
1114 memcpy(&proxy_addr->sin_addr.s_addr, he->h_addr_list[0], he->h_length);
1115 proxy_addr->sin_port = htons(port);
1118 static void http_fire_observers(struct http_channel *c)
1120 http_channel_observer_t p = c->observers;
1123 p->destroy(p->data, c);
1128 static void http_destroy_observers(struct http_channel *c)
1130 while (c->observers)
1132 http_channel_observer_t obs = c->observers;
1133 c->observers = obs->next;
1138 http_channel_observer_t http_add_observer(struct http_channel *c, void *data,
1139 http_channel_destroy_t des)
1141 http_channel_observer_t obs = xmalloc(sizeof(*obs));
1145 obs->next = c->observers;
1150 void http_remove_observer(http_channel_observer_t obs)
1152 struct http_channel *c = obs->chan;
1153 http_channel_observer_t found, *p = &c->observers;
1162 struct http_channel *http_channel_observer_chan(http_channel_observer_t obs)
1170 * indent-tabs-mode: nil
1172 * vim: shiftwidth=4 tabstop=8 expandtab