}
}
-static void set_basic_http_header(apr_table_t *headers, request_rec *r,
- apr_pool_t *pool)
-{
- char *date = NULL;
- const char *proxy_date = NULL;
- const char *server = NULL;
- const char *us = ap_get_server_banner();
-
- /*
- * keep the set-by-proxy server and date headers, otherwise
- * generate a new server header / date header
- */
- if (r && r->proxyreq != PROXYREQ_NONE) {
- proxy_date = apr_table_get(r->headers_out, "Date");
- if (!proxy_date) {
- /*
- * proxy_date needs to be const. So use date for the creation of
- * our own Date header and pass it over to proxy_date later to
- * avoid a compiler warning.
- */
- date = apr_palloc(pool, APR_RFC822_DATE_LEN);
- ap_recent_rfc822_date(date, r->request_time);
- }
- server = apr_table_get(r->headers_out, "Server");
- }
- else {
- date = apr_palloc(pool, APR_RFC822_DATE_LEN);
- ap_recent_rfc822_date(date, r? r->request_time : apr_time_now());
- }
-
- apr_table_setn(headers, "Date", proxy_date ? proxy_date : date );
- if (r) {
- apr_table_unset(r->headers_out, "Date");
- }
-
- if (!server && *us) {
- server = us;
- }
- if (server) {
- apr_table_setn(headers, "Server", server);
- if (r) {
- apr_table_unset(r->headers_out, "Server");
- }
- }
-}
-
-static int copy_header(void *ctx, const char *name, const char *value)
-{
- apr_table_t *headers = ctx;
-
- apr_table_add(headers, name, value);
- return 1;
-}
-
static h2_headers *create_response(h2_task *task, request_rec *r)
{
const char *clheader;
const char *ctype;
- apr_table_t *headers;
+
/*
* Now that we are ready to send a response, we need to combine the two
* header field tables into a single table. If we don't do this, our
apr_table_unset(r->headers_out, "Content-Length");
}
- headers = apr_table_make(r->pool, 10);
- set_basic_http_header(headers, r, r->pool);
- apr_table_do(copy_header, headers, r->headers_out, NULL);
+ /*
+ * keep the set-by-proxy server and date headers, otherwise
+ * generate a new server header / date header
+ */
+ if (r->proxyreq != PROXYREQ_RESPONSE
+ || !apr_table_get(r->headers_out, "Date")) {
+ char *date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
+ ap_recent_rfc822_date(date, r? r->request_time : apr_time_now());
+ apr_table_setn(r->headers_out, "Date", date );
+ }
+ if (r->proxyreq != PROXYREQ_RESPONSE) {
+ const char *us = ap_get_server_banner();
+ if (us) {
+ apr_table_setn(r->headers_out, "Server", us);
+ }
+ }
- return h2_headers_rcreate(r, r->status, headers, r->pool);
+ return h2_headers_rcreate(r, r->status, r->headers_out, r->pool);
}
typedef enum {
}
-h2_headers *h2_headers_create(int status, apr_table_t *headers_in,
- apr_table_t *notes, apr_off_t raw_bytes,
- apr_pool_t *pool)
+h2_headers *h2_headers_create(int status, const apr_table_t *headers_in,
+ const apr_table_t *notes, apr_off_t raw_bytes,
+ apr_pool_t *pool)
{
h2_headers *headers = apr_pcalloc(pool, sizeof(h2_headers));
headers->status = status;
}
h2_headers *h2_headers_rcreate(request_rec *r, int status,
- apr_table_t *header, apr_pool_t *pool)
+ const apr_table_t *header, apr_pool_t *pool)
{
h2_headers *headers = h2_headers_create(status, header, r->notes, 0, pool);
if (headers->status == HTTP_FORBIDDEN) {
h2_headers *h2_headers_copy(apr_pool_t *pool, h2_headers *h)
{
- return h2_headers_create(h->status, apr_table_copy(pool, h->headers),
- apr_table_copy(pool, h->notes), h->raw_bytes, pool);
+ return h2_headers_create(h->status, h->headers, h->notes, h->raw_bytes, pool);
}
h2_headers *h2_headers_clone(apr_pool_t *pool, h2_headers *h)
{
- return h2_headers_create(h->status, apr_table_clone(pool, h->headers),
- apr_table_clone(pool, h->notes), h->raw_bytes, pool);
+ return h2_headers_create(h->status, h->headers, h->notes, h->raw_bytes, pool);
}
h2_headers *h2_headers_die(apr_status_t type,
* @param raw_bytes the raw network bytes (if known) used to transmit these
* @param pool the memory pool to use
*/
-h2_headers *h2_headers_create(int status, apr_table_t *header,
- apr_table_t *notes, apr_off_t raw_bytes,
+h2_headers *h2_headers_create(int status, const apr_table_t *header,
+ const apr_table_t *notes, apr_off_t raw_bytes,
apr_pool_t *pool);
/**
* @param pool the memory pool to use
*/
h2_headers *h2_headers_rcreate(request_rec *r, int status,
- apr_table_t *header, apr_pool_t *pool);
+ const apr_table_t *header, apr_pool_t *pool);
/**
* Copy the headers into another pool. This will not copy any