Skip to content

Commit f738419

Browse files
committed
Merge r1934913 from trunk:
Use HTTP_* and ap_is_*() macros instead of literals Submitted by: michaelo Reviewed by: rjung, jim, jorton git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1935938 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9407b22 commit f738419

23 files changed

Lines changed: 63 additions & 65 deletions

modules/aaa/mod_authn_socache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int authn_cache_post_config(apr_pool_t *pconf, apr_pool_t *plog,
111111
ap_log_perror(APLOG_MARK, APLOG_CRIT, 0, plog, APLOGNO(02612)
112112
"failed to create mod_socache_shmcb socache "
113113
"instance: %s", errmsg);
114-
return 500;
114+
return 500; /* An HTTP status would be a misnomer! */
115115
}
116116
}
117117

modules/cache/mod_cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,10 +1687,10 @@ static apr_status_t cache_invalidate_filter(ap_filter_t *f,
16871687
}
16881688
else {
16891689

1690-
if (r->status > 299) {
1690+
if (r->status >= HTTP_MULTIPLE_CHOICES) {
16911691

16921692
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02466)
1693-
"cache: response status to '%s' method is %d (>299), not invalidating cached entity: %s", r->method, r->status, r->uri);
1693+
"cache: response status to '%s' method is %d (>=HTTP_MULTIPLE_CHOICES), not invalidating cached entity: %s", r->method, r->status, r->uri);
16941694

16951695
}
16961696
else {

modules/dav/main/mod_dav.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ static int dav_method_put(request_rec *r)
10761076
if ((err = (*resource->hooks->open_stream)(resource, mode,
10771077
&stream)) != NULL) {
10781078
int status = err->status ? err->status : HTTP_FORBIDDEN;
1079-
if (status > 299) {
1079+
if (status >= HTTP_MULTIPLE_CHOICES) {
10801080
err = dav_push_error(r->pool, status, 0,
10811081
apr_psprintf(r->pool,
10821082
"Unable to PUT new contents for %s.",

modules/dav/main/mod_dav.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ DAV_DECLARE_NONSTD(void) dav_prop_exec(dav_prop_ctx *ctx);
17921792
DAV_DECLARE_NONSTD(void) dav_prop_commit(dav_prop_ctx *ctx);
17931793
DAV_DECLARE_NONSTD(void) dav_prop_rollback(dav_prop_ctx *ctx);
17941794

1795-
#define DAV_PROP_CTX_HAS_ERR(dpc) ((dpc).err && (dpc).err->status >= 300)
1795+
#define DAV_PROP_CTX_HAS_ERR(dpc) ((dpc).err && (dpc).err->status >= HTTP_MULTIPLE_CHOICES)
17961796

17971797

17981798
/* --------------------------------------------------------------------

modules/filters/mod_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static apr_status_t filter_harness(ap_filter_t *f, apr_bucket_brigade *bb)
280280
harness_ctx *ctx = f->ctx;
281281
ap_filter_rec_t *filter = f->frec;
282282

283-
if (f->r->status != 200
283+
if (f->r->status != HTTP_OK
284284
&& !apr_table_get(f->r->subprocess_env, "filter-errordocs")) {
285285
ap_remove_output_filter(f);
286286
return ap_pass_brigade(f->next, bb);

modules/generators/cgi_common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb,
480480

481481
location = apr_table_get(r->headers_out, "Location");
482482

483-
if (location && r->status == 200) {
483+
if (location && r->status == HTTP_OK) {
484484
/* For a redirect whether internal or not, discard any
485485
* remaining stdout from the script, and log any remaining
486486
* stderr output, as normal. */
@@ -493,7 +493,7 @@ static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb,
493493
}
494494
}
495495

496-
if (location && location[0] == '/' && r->status == 200) {
496+
if (location && location[0] == '/' && r->status == HTTP_OK) {
497497
/* This redirect needs to be a GET no matter what the original
498498
* method was.
499499
*/
@@ -509,7 +509,7 @@ static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb,
509509
ap_internal_redirect_handler(location, r);
510510
return OK;
511511
}
512-
else if (location && r->status == 200) {
512+
else if (location && r->status == HTTP_OK) {
513513
/* XXX: Note that if a script wants to produce its own Redirect
514514
* body, it now has to explicitly *say* "Status: 302"
515515
*/

modules/http2/h2_c2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static apr_status_t h2_c2_filter_out(ap_filter_t* f, apr_bucket_brigade* bb)
395395
{
396396
if (AP_BUCKET_IS_RESPONSE(e)) {
397397
ap_bucket_response *resp = e->data;
398-
if (resp->status >= 200) {
398+
if (resp->status >= HTTP_OK) {
399399
conn_ctx->has_final_response = 1;
400400
break;
401401
}
@@ -461,7 +461,7 @@ static void check_early_hints(request_rec *r, const char *tag)
461461
}
462462
old_status = r->status;
463463
old_line = r->status_line;
464-
r->status = 103;
464+
r->status = HTTP_EARLY_HINTS;
465465
r->status_line = "103 Early Hints";
466466
ap_send_interim_response(r, 1);
467467
r->status = old_status;

modules/http2/h2_c2_filter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ apr_status_t h2_c2_filter_notes_out(ap_filter_t *f, apr_bucket_brigade *bb)
6262
{
6363
if (AP_BUCKET_IS_RESPONSE(b)) {
6464
resp = b->data;
65-
if (resp->status >= 400 && f->r->prev) {
65+
if (resp->status >= HTTP_BAD_REQUEST && f->r->prev) {
6666
/* Error responses are commonly handled via internal
6767
* redirects to error documents. That creates a new
6868
* 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,
547547
parser->state = H2_RP_STATUS_LINE;
548548
apr_array_clear(parser->hlines);
549549

550-
if (response->status >= 200) {
550+
if (response->status >= HTTP_OK) {
551551
conn_ctx->has_final_response = 1;
552552
}
553553
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)
657657
HTTP_INTERNAL_SERVER_ERROR);
658658
request_rec *r = h2_create_request_rec(conn_ctx->request, f->c, 1);
659659
if (r) {
660-
ap_die((result >= 400)? result : HTTP_INTERNAL_SERVER_ERROR, r);
660+
ap_die((result >= HTTP_BAD_REQUEST)? result : HTTP_INTERNAL_SERVER_ERROR, r);
661661
b = ap_bucket_eor_create(f->c->bucket_alloc, r);
662662
APR_BRIGADE_INSERT_TAIL(bb, b);
663663
}

modules/http2/h2_headers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ h2_headers *h2_headers_die(apr_status_t type,
199199
char *date;
200200

201201
headers = apr_pcalloc(pool, sizeof(h2_headers));
202-
headers->status = (type >= 200 && type < 600)? type : 500;
202+
headers->status = (type >= HTTP_OK && type < 600)? type : HTTP_INTERNAL_SERVER_ERROR;
203203
headers->headers = apr_table_make(pool, 5);
204204
headers->notes = apr_table_make(pool, 5);
205205

@@ -213,7 +213,7 @@ h2_headers *h2_headers_die(apr_status_t type,
213213

214214
int h2_headers_are_final_response(h2_headers *headers)
215215
{
216-
return headers->status >= 200;
216+
return headers->status >= HTTP_OK;
217217
}
218218

219219
#endif /* !AP_HAS_RESPONSE_BUCKETS */

modules/http2/h2_proxy_session.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,24 +281,18 @@ static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame,
281281
return NGHTTP2_ERR_CALLBACK_FAILURE;
282282
}
283283
r = stream->r;
284-
if (r->status >= 100 && r->status < 200) {
284+
if (ap_is_HTTP_INFO(r->status)) {
285285
/* By default, we will forward all interim responses when
286286
* we are sitting on a HTTP/2 connection to the client */
287287
int forward = session->h2_front;
288288
switch(r->status) {
289-
case 100:
289+
case HTTP_CONTINUE:
290290
if (stream->waiting_on_100) {
291291
stream->waiting_on_100 = 0;
292292
r->status_line = ap_get_status_line(r->status);
293293
forward = 1;
294294
}
295295
break;
296-
case 103:
297-
/* workaround until we get this into http protocol base
298-
* parts. without this, unknown codes are converted to
299-
* 500... */
300-
r->status_line = "103 Early Hints";
301-
break;
302296
default:
303297
r->status_line = ap_get_status_line(r->status);
304298
break;
@@ -311,7 +305,7 @@ static int on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame,
311305
ap_send_interim_response(r, 1);
312306
}
313307
}
314-
else if (r->status >= 400) {
308+
else if (r->status >= HTTP_BAD_REQUEST) {
315309
proxy_dir_conf *dconf;
316310
dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
317311
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,
417411
stream->session->id, stream->id, s);
418412
stream->r->status = (int)apr_atoi64(s);
419413
if (stream->r->status <= 0) {
420-
stream->r->status = 500;
414+
stream->r->status = HTTP_INTERNAL_SERVER_ERROR;
421415
return APR_EGENERAL;
422416
}
423417
}
@@ -509,7 +503,7 @@ static void h2_proxy_stream_end_headers_out(h2_proxy_stream *stream)
509503
server_name, portstr)
510504
);
511505
}
512-
if (r->status >= 200) stream->headers_ended = 1;
506+
if (r->status >= HTTP_OK) stream->headers_ended = 1;
513507

514508
if (APLOGrtrace2(stream->r)) {
515509
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, stream->r,

0 commit comments

Comments
 (0)