Skip to content

Commit bddcfb1

Browse files
committed
* mod_proxy_http2: add support for ProxyErrorOverride directive. PR69771
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1927647 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1356c5e commit bddcfb1

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

changes-entries/pr69771.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* mod_proxy_http2: add support for ProxyErrorOverride directive. PR69771

modules/http2/h2_proxy_session.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef struct h2_proxy_stream {
4949
unsigned int waiting_on_ping : 1;
5050
unsigned int headers_ended : 1;
5151
uint32_t error_code;
52+
int proxy_status;
5253

5354
apr_bucket_brigade *input;
5455
apr_off_t data_sent;
@@ -310,6 +311,15 @@ static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame,
310311
ap_send_interim_response(r, 1);
311312
}
312313
}
314+
else if (r->status >= 400) {
315+
proxy_dir_conf *dconf;
316+
dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
317+
if (ap_proxy_should_override(dconf, r->status)) {
318+
apr_table_setn(r->notes, "proxy-error-override", "1");
319+
nghttp2_submit_rst_stream(ngh2, NGHTTP2_FLAG_NONE,
320+
frame->hd.stream_id, NGHTTP2_STREAM_CLOSED);
321+
}
322+
}
313323
stream_resume(stream);
314324
break;
315325
case NGHTTP2_PING:

modules/http2/h2_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
* @macro
2828
* Version number of the http2 module as c string
2929
*/
30-
#define MOD_HTTP2_VERSION "2.0.32"
30+
#define MOD_HTTP2_VERSION "2.0.34"
3131

3232
/**
3333
* @macro
3434
* Numerical representation of the version number of the http2 module
3535
* release. This is a 24 bit number with 8 bits for major number, 8 bits
3636
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
3737
*/
38-
#define MOD_HTTP2_VERSION_NUM 0x020020
38+
#define MOD_HTTP2_VERSION_NUM 0x020022
3939

4040

4141
#endif /* mod_h2_h2_version_h */

modules/http2/mod_proxy_http2.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,15 @@ static void request_done(h2_proxy_ctx *ctx, request_rec *r,
239239
ctx->id, touched, error_code);
240240
ctx->r_done = 1;
241241
if (touched) ctx->r_may_retry = 0;
242-
ctx->r_status = error_code? HTTP_BAD_GATEWAY :
243-
((status == APR_SUCCESS)? OK :
244-
ap_map_http_request_error(status, HTTP_SERVICE_UNAVAILABLE));
242+
if (apr_table_get(r->notes, "proxy-error-override")) {
243+
ctx->r_status = r->status;
244+
r->status = OK;
245+
}
246+
else {
247+
ctx->r_status = error_code? HTTP_BAD_GATEWAY :
248+
((status == APR_SUCCESS)? OK :
249+
ap_map_http_request_error(status, HTTP_SERVICE_UNAVAILABLE));
250+
}
245251
}
246252
}
247253

@@ -428,7 +434,12 @@ static int proxy_http2_handler(request_rec *r,
428434
if (ctx->cfront->aborted) goto cleanup;
429435
status = ctx_run(ctx);
430436

431-
if (ctx->r_status != APR_SUCCESS && ctx->r_may_retry && !ctx->cfront->aborted) {
437+
if (apr_table_get(r->notes, "proxy-error-override")) {
438+
/* pass on out */
439+
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, ctx->cfront,
440+
"proxy-error-override status %d", ctx->r_status);
441+
}
442+
else if (ctx->r_status != APR_SUCCESS && ctx->r_may_retry && !ctx->cfront->aborted) {
432443
/* Not successfully processed, but may retry, tear down old conn and start over */
433444
if (ctx->p_conn) {
434445
ctx->p_conn->close = 1;
@@ -463,7 +474,7 @@ static int proxy_http2_handler(request_rec *r,
463474

464475
ap_set_module_config(ctx->cfront->conn_config, &proxy_http2_module, NULL);
465476
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, ctx->cfront,
466-
APLOGNO(03377) "leaving handler");
477+
APLOGNO(03377) "leaving handler -> %d", ctx->r_status);
467478
return ctx->r_status;
468479
}
469480

0 commit comments

Comments
 (0)