From: reyk Date: Sun, 3 Aug 2014 12:26:19 +0000 (+0000) Subject: Add function to iterate all headers. No functional change. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b2bd9ec76f8ad08218df829f3e1e18f7c538e056;p=openbsd Add function to iterate all headers. No functional change. --- diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index b7f6b351a3b..6609f0d632c 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $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 @@ -446,8 +446,8 @@ const char *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); diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c index 63978d9735e..9c77181e32b 100644 --- a/usr.sbin/httpd/server_fcgi.c +++ b/usr.sbin/httpd/server_fcgi.c @@ -1,4 +1,4 @@ -/* $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 @@ -546,7 +546,7 @@ server_fcgi_header(struct client *clt, u_int code) /* 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); diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 6da7cf146a9..27d7fbc4ee8 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $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 @@ -818,7 +818,7 @@ server_response_http(struct client *clt, u_int code, /* 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); @@ -854,7 +854,7 @@ server_writeresponse_http(struct client *clt) } int -server_writeheader_kv(struct client *clt, struct kv *hdr) +server_writeheader_http(struct client *clt, struct kv *hdr) { char *ptr; const char *key; @@ -882,16 +882,16 @@ server_writeheader_kv(struct client *clt, struct kv *hdr) } 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); } }