diff --git a/mod_http2/h2_c2.c b/mod_http2/h2_c2.c index 5a9019aa..79f76c0a 100644 --- a/mod_http2/h2_c2.c +++ b/mod_http2/h2_c2.c @@ -395,7 +395,7 @@ static apr_status_t h2_c2_filter_out(ap_filter_t* f, apr_bucket_brigade* bb) { if (AP_BUCKET_IS_RESPONSE(e)) { ap_bucket_response *resp = e->data; - if (resp->status >= 200) { + if (resp->status >= HTTP_OK) { conn_ctx->has_final_response = 1; break; } @@ -461,8 +461,13 @@ static void check_early_hints(request_rec *r, const char *tag) } old_status = r->status; old_line = r->status_line; +#ifdef HTTP_EARLY_HINTS + r->status = HTTP_EARLY_HINTS; + r->status_line = ap_get_status_line(r->status); +#else r->status = 103; r->status_line = "103 Early Hints"; +#endif ap_send_interim_response(r, 1); r->status = old_status; r->status_line = old_line; diff --git a/mod_http2/h2_c2_filter.c b/mod_http2/h2_c2_filter.c index d770fe91..17a2c131 100644 --- a/mod_http2/h2_c2_filter.c +++ b/mod_http2/h2_c2_filter.c @@ -62,7 +62,7 @@ apr_status_t h2_c2_filter_notes_out(ap_filter_t *f, apr_bucket_brigade *bb) { if (AP_BUCKET_IS_RESPONSE(b)) { resp = b->data; - if (resp->status >= 400 && f->r->prev) { + if (resp->status >= HTTP_BAD_REQUEST && f->r->prev) { /* Error responses are commonly handled via internal * redirects to error documents. That creates a new * request_rec with 'prev' set to the original. @@ -547,7 +547,7 @@ static apr_status_t pass_response(h2_conn_ctx_t *conn_ctx, ap_filter_t *f, parser->state = H2_RP_STATUS_LINE; apr_array_clear(parser->hlines); - if (response->status >= 200) { + if (response->status >= HTTP_OK) { conn_ctx->has_final_response = 1; } ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, parser->c, @@ -657,7 +657,7 @@ apr_status_t h2_c2_filter_catch_h1_out(ap_filter_t* f, apr_bucket_brigade* bb) HTTP_INTERNAL_SERVER_ERROR); request_rec *r = h2_create_request_rec(conn_ctx->request, f->c, 1); if (r) { - ap_die((result >= 400)? result : HTTP_INTERNAL_SERVER_ERROR, r); + ap_die((result >= HTTP_BAD_REQUEST)? result : HTTP_INTERNAL_SERVER_ERROR, r); b = ap_bucket_eor_create(f->c->bucket_alloc, r); APR_BRIGADE_INSERT_TAIL(bb, b); } diff --git a/mod_http2/h2_headers.c b/mod_http2/h2_headers.c index d9b3fd09..c21a360b 100644 --- a/mod_http2/h2_headers.c +++ b/mod_http2/h2_headers.c @@ -199,7 +199,7 @@ h2_headers *h2_headers_die(apr_status_t type, char *date; headers = apr_pcalloc(pool, sizeof(h2_headers)); - headers->status = (type >= 200 && type < 600)? type : 500; + headers->status = (type >= HTTP_OK && type < 600)? type : HTTP_INTERNAL_SERVER_ERROR; headers->headers = apr_table_make(pool, 5); headers->notes = apr_table_make(pool, 5); @@ -213,7 +213,7 @@ h2_headers *h2_headers_die(apr_status_t type, int h2_headers_are_final_response(h2_headers *headers) { - return headers->status >= 200; + return headers->status >= HTTP_OK; } #endif /* !AP_HAS_RESPONSE_BUCKETS */ diff --git a/mod_http2/h2_proxy_session.c b/mod_http2/h2_proxy_session.c index 166b6468..f5f0f0d6 100644 --- a/mod_http2/h2_proxy_session.c +++ b/mod_http2/h2_proxy_session.c @@ -281,24 +281,26 @@ static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame, return NGHTTP2_ERR_CALLBACK_FAILURE; } r = stream->r; - if (r->status >= 100 && r->status < 200) { + if (ap_is_HTTP_INFO(r->status)) { /* By default, we will forward all interim responses when * we are sitting on a HTTP/2 connection to the client */ int forward = session->h2_front; switch(r->status) { - case 100: + case HTTP_CONTINUE: if (stream->waiting_on_100) { stream->waiting_on_100 = 0; r->status_line = ap_get_status_line(r->status); forward = 1; } break; +#ifndef HTTP_EARLY_HINTS case 103: /* workaround until we get this into http protocol base * parts. without this, unknown codes are converted to * 500... */ r->status_line = "103 Early Hints"; break; +#endif default: r->status_line = ap_get_status_line(r->status); break; @@ -311,7 +313,7 @@ static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame, ap_send_interim_response(r, 1); } } - else if (r->status >= 400) { + else if (r->status >= HTTP_BAD_REQUEST) { proxy_dir_conf *dconf; dconf = ap_get_module_config(r->per_dir_config, &proxy_module); if (ap_proxy_should_override(dconf, r->status)) { @@ -417,7 +419,7 @@ static apr_status_t h2_proxy_stream_add_header_out(h2_proxy_stream *stream, stream->session->id, stream->id, s); stream->r->status = (int)apr_atoi64(s); if (stream->r->status <= 0) { - stream->r->status = 500; + stream->r->status = HTTP_INTERNAL_SERVER_ERROR; return APR_EGENERAL; } } @@ -509,7 +511,7 @@ static void h2_proxy_stream_end_headers_out(h2_proxy_stream *stream) server_name, portstr) ); } - if (r->status >= 200) stream->headers_ended = 1; + if (r->status >= HTTP_OK) stream->headers_ended = 1; if (APLOGrtrace2(stream->r)) { ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, stream->r, diff --git a/mod_http2/h2_stream.c b/mod_http2/h2_stream.c index f0e671ca..44969cf0 100644 --- a/mod_http2/h2_stream.c +++ b/mod_http2/h2_stream.c @@ -1022,10 +1022,10 @@ static void stream_do_error_bucket(h2_stream *stream, apr_bucket *b) int err = ((ap_bucket_error *)(b->data))->status; ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c1, H2_STRM_MSG(stream, "error bucket received, err=%d"), err); - if (err >= 500) { + if (err >= HTTP_INTERNAL_SERVER_ERROR) { err = NGHTTP2_INTERNAL_ERROR; } - else if (err >= 400) { + else if (err >= HTTP_BAD_REQUEST) { err = NGHTTP2_STREAM_CLOSED; } else { @@ -1649,7 +1649,7 @@ static apr_status_t stream_do_response(h2_stream *stream) goto cleanup; } - if (resp->status < 100) { + if (resp->status < HTTP_CONTINUE) { h2_stream_rst(stream, resp->status); goto cleanup; } @@ -1691,8 +1691,8 @@ static apr_status_t stream_do_response(h2_stream *stream) && !stream->response && stream->request && stream->request->method && !strcmp("GET", stream->request->method) - && (resp->status < 400) - && (resp->status != 304) + && (resp->status < HTTP_BAD_REQUEST) + && (resp->status != HTTP_NOT_MODIFIED) && h2_session_push_enabled(stream->session)) { /* PUSH is possible and enabled on server, unless the request * denies it, submit resources to push */ @@ -1709,14 +1709,18 @@ static apr_status_t stream_do_response(h2_stream *stream) } h2_session_set_prio(stream->session, stream, stream->pref_priority); +#ifdef HTTP_EARLY_HINTS + if (resp->status == HTTP_EARLY_HINTS +#else if (resp->status == 103 +#endif && !h2_config_sgeti(stream->session->s, H2_CONF_EARLY_HINTS)) { /* suppress sending this to the client, it might have triggered * pushes and served its purpose nevertheless */ rv = APR_SUCCESS; goto cleanup; } - if (resp->status >= 200) { + if (resp->status >= HTTP_OK) { stream->response = resp; } diff --git a/mod_http2/h2_ws.c b/mod_http2/h2_ws.c index 4643660f..9e3d5087 100644 --- a/mod_http2/h2_ws.c +++ b/mod_http2/h2_ws.c @@ -247,10 +247,10 @@ static void ws_handle_resp(conn_rec *c2, h2_conn_ctx_t *conn_ctx, override_body = is_final = 1; } } - else if (resp->status < 200) { + else if (resp->status < HTTP_OK) { /* other intermediate response, pass through */ } - else if (resp->status < 300) { + else if (resp->status < HTTP_MULTIPLE_CHOICES) { /* Failure, we might be talking to a plain http resource */ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c2, "h2_c2(%s-%d): websocket CONNECT, invalid response %d",