From dfb93c2457dd8a957bbfa0bdabde56e1ea768a0b Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 5 Jun 2026 16:40:45 +0100 Subject: [PATCH 1/3] Merge r1934913 from httpd trunk: Use HTTP_* and ap_is_*() macros instead of literals Reference: https://svn.apache.org/viewvc/?view=revision&revision=1934913 --- mod_http2/h2_c2.c | 4 ++-- mod_http2/h2_c2_filter.c | 6 +++--- mod_http2/h2_headers.c | 4 ++-- mod_http2/h2_proxy_session.c | 16 +++++----------- mod_http2/h2_stream.c | 14 +++++++------- mod_http2/h2_ws.c | 4 ++-- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/mod_http2/h2_c2.c b/mod_http2/h2_c2.c index 5a9019aa..3ca6114d 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,7 +461,7 @@ static void check_early_hints(request_rec *r, const char *tag) } old_status = r->status; old_line = r->status_line; - r->status = 103; + r->status = HTTP_EARLY_HINTS; r->status_line = "103 Early Hints"; ap_send_interim_response(r, 1); r->status = old_status; 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..f1634eec 100644 --- a/mod_http2/h2_proxy_session.c +++ b/mod_http2/h2_proxy_session.c @@ -281,24 +281,18 @@ 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; - 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; default: r->status_line = ap_get_status_line(r->status); break; @@ -311,7 +305,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 +411,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 +503,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..653af3fb 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,14 @@ static apr_status_t stream_do_response(h2_stream *stream) } h2_session_set_prio(stream->session, stream, stream->pref_priority); - if (resp->status == 103 + if (resp->status == HTTP_EARLY_HINTS && !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", From 2deb276d0fb4a69f73c7a2fb5fe411159cec0c6c Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 5 Jun 2026 16:40:47 +0100 Subject: [PATCH 2/3] Merge r1934914 from httpd trunk: Use ap_get_status_line() instead of string literals Reference: https://svn.apache.org/viewvc/?view=revision&revision=1934914 --- mod_http2/h2_c2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod_http2/h2_c2.c b/mod_http2/h2_c2.c index 3ca6114d..ad30f96d 100644 --- a/mod_http2/h2_c2.c +++ b/mod_http2/h2_c2.c @@ -462,7 +462,7 @@ static void check_early_hints(request_rec *r, const char *tag) old_status = r->status; old_line = r->status_line; r->status = HTTP_EARLY_HINTS; - r->status_line = "103 Early Hints"; + r->status_line = ap_get_status_line(r->status); ap_send_interim_response(r, 1); r->status = old_status; r->status_line = old_line; From 0a57f457215683ebef9bd238854be9657f2c3341 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 5 Jun 2026 17:13:29 +0100 Subject: [PATCH 3/3] Partial revert of r1934913, more safely. --- mod_http2/h2_c2.c | 5 +++++ mod_http2/h2_proxy_session.c | 8 ++++++++ mod_http2/h2_stream.c | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/mod_http2/h2_c2.c b/mod_http2/h2_c2.c index ad30f96d..79f76c0a 100644 --- a/mod_http2/h2_c2.c +++ b/mod_http2/h2_c2.c @@ -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_proxy_session.c b/mod_http2/h2_proxy_session.c index f1634eec..f5f0f0d6 100644 --- a/mod_http2/h2_proxy_session.c +++ b/mod_http2/h2_proxy_session.c @@ -293,6 +293,14 @@ static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame, 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; diff --git a/mod_http2/h2_stream.c b/mod_http2/h2_stream.c index 653af3fb..44969cf0 100644 --- a/mod_http2/h2_stream.c +++ b/mod_http2/h2_stream.c @@ -1709,7 +1709,11 @@ 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 */