-/* $OpenBSD: httpd.h,v 1.35 2014/08/03 11:16:10 reyk Exp $ */
+/* $OpenBSD: httpd.h,v 1.36 2014/08/03 12:26:19 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
*server_httperror_byid(u_int);
void server_read_httpcontent(struct bufferevent *, void *);
void server_read_httpchunks(struct bufferevent *, void *);
-int server_writeheader_kv(struct client *, struct kv *);
-int server_writeheader_http(struct client *);
+int server_writeheader_http(struct client *clt, struct kv *);
+int server_headers(struct client *, int (*)(struct client *, struct kv *));
int server_writeresponse_http(struct client *);
int server_response_http(struct client *, u_int, struct media_type *,
size_t);
-/* $OpenBSD: server_fcgi.c,v 1.14 2014/08/03 11:16:10 reyk Exp $ */
+/* $OpenBSD: server_fcgi.c,v 1.15 2014/08/03 12:26:19 reyk Exp $ */
/*
* Copyright (c) 2014 Florian Obser <florian@openbsd.org>
/* Write initial header (fcgi might append more) */
if (server_writeresponse_http(clt) == -1 ||
server_bufferevent_print(clt, "\r\n") == -1 ||
- server_writeheader_http(clt) == -1)
+ server_headers(clt, server_writeheader_http) == -1)
return (-1);
return (0);
-/* $OpenBSD: server_http.c,v 1.30 2014/08/03 10:26:44 reyk Exp $ */
+/* $OpenBSD: server_http.c,v 1.31 2014/08/03 12:26:19 reyk Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
/* Write completed header */
if (server_writeresponse_http(clt) == -1 ||
server_bufferevent_print(clt, "\r\n") == -1 ||
- server_writeheader_http(clt) == -1 ||
+ server_headers(clt, server_writeheader_http) == -1 ||
server_bufferevent_print(clt, "\r\n") == -1)
return (-1);
}
int
-server_writeheader_kv(struct client *clt, struct kv *hdr)
+server_writeheader_http(struct client *clt, struct kv *hdr)
{
char *ptr;
const char *key;
}
int
-server_writeheader_http(struct client *clt)
+server_headers(struct client *clt, int (*hdr_cb)(struct client *, struct kv *))
{
struct kv *hdr, *kv;
struct http_descriptor *desc = (struct http_descriptor *)clt->clt_desc;
RB_FOREACH(hdr, kvtree, &desc->http_headers) {
- if (server_writeheader_kv(clt, hdr) == -1)
+ if ((hdr_cb)(clt, hdr) == -1)
return (-1);
TAILQ_FOREACH(kv, &hdr->kv_children, kv_entry) {
- if (server_writeheader_kv(clt, kv) == -1)
+ if ((hdr_cb)(clt, kv) == -1)
return (-1);
}
}