summaryrefslogtreecommitdiff
path: root/modules/http2/h2_from_h1.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/http2/h2_from_h1.c')
-rw-r--r--modules/http2/h2_from_h1.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/modules/http2/h2_from_h1.c b/modules/http2/h2_from_h1.c
index 8e1f163a..0f893ec1 100644
--- a/modules/http2/h2_from_h1.c
+++ b/modules/http2/h2_from_h1.c
@@ -31,7 +31,6 @@
#include "h2_response.h"
#include "h2_from_h1.h"
#include "h2_task.h"
-#include "h2_task_output.h"
#include "h2_util.h"
@@ -292,7 +291,8 @@ static void fix_vary(request_rec *r)
}
}
-static void set_basic_http_header(request_rec *r, apr_table_t *headers)
+void h2_from_h1_set_basic_http_header(apr_table_t *headers, request_rec *r,
+ apr_pool_t *pool)
{
char *date = NULL;
const char *proxy_date = NULL;
@@ -303,7 +303,7 @@ static void set_basic_http_header(request_rec *r, apr_table_t *headers)
* keep the set-by-proxy server and date headers, otherwise
* generate a new server header / date header
*/
- if (r->proxyreq != PROXYREQ_NONE) {
+ if (r && r->proxyreq != PROXYREQ_NONE) {
proxy_date = apr_table_get(r->headers_out, "Date");
if (!proxy_date) {
/*
@@ -311,25 +311,29 @@ static void set_basic_http_header(request_rec *r, apr_table_t *headers)
* our own Date header and pass it over to proxy_date later to
* avoid a compiler warning.
*/
- date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
+ 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(r->pool, APR_RFC822_DATE_LEN);
- ap_recent_rfc822_date(date, r->request_time);
+ 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 );
- apr_table_unset(r->headers_out, "Date");
+ if (r) {
+ apr_table_unset(r->headers_out, "Date");
+ }
if (!server && *us) {
server = us;
}
if (server) {
apr_table_setn(headers, "Server", server);
- apr_table_unset(r->headers_out, "Server");
+ if (r) {
+ apr_table_unset(r->headers_out, "Server");
+ }
}
}
@@ -446,7 +450,7 @@ static h2_response *create_response(h2_from_h1 *from_h1, request_rec *r)
headers = apr_table_make(r->pool, 10);
- set_basic_http_header(r, headers);
+ h2_from_h1_set_basic_http_header(headers, r, r->pool);
if (r->status == HTTP_NOT_MODIFIED) {
apr_table_do((int (*)(void *, const char *, const char *)) copy_header,
(void *) headers, r->headers_out,
@@ -473,7 +477,7 @@ static h2_response *create_response(h2_from_h1 *from_h1, request_rec *r)
apr_status_t h2_response_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
h2_task *task = f->ctx;
- h2_from_h1 *from_h1 = task->output? task->output->from_h1 : NULL;
+ h2_from_h1 *from_h1 = task->output.from_h1;
request_rec *r = f->r;
apr_bucket *b;
ap_bucket_error *eb = NULL;
@@ -483,7 +487,7 @@ apr_status_t h2_response_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, f->c,
"h2_from_h1(%d): output_filter called", from_h1->stream_id);
- if (r->header_only && task->output && from_h1->response) {
+ if (r->header_only && from_h1->response) {
/* throw away any data after we have compiled the response */
apr_brigade_cleanup(bb);
return OK;
@@ -552,7 +556,7 @@ apr_status_t h2_response_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
apr_status_t h2_response_trailers_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
h2_task *task = f->ctx;
- h2_from_h1 *from_h1 = task->output? task->output->from_h1 : NULL;
+ h2_from_h1 *from_h1 = task->output.from_h1;
request_rec *r = f->r;
apr_bucket *b;