]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Use HTTP_* and ap_is_*() macros instead of literals
authorMichael Osipov <michaelo@apache.org>
Wed, 3 Jun 2026 09:07:51 +0000 (09:07 +0000)
committerMichael Osipov <michaelo@apache.org>
Wed, 3 Jun 2026 09:07:51 +0000 (09:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1934913 13f79535-47bb-0310-9956-ffa450edef68

26 files changed:
include/httpd.h
modules/aaa/mod_authn_socache.c
modules/cache/mod_cache.c
modules/dav/main/mod_dav.c
modules/dav/main/mod_dav.h
modules/filters/mod_filter.c
modules/generators/cgi_common.h
modules/http/http_filters.c
modules/http2/h2_c2.c
modules/http2/h2_c2_filter.c
modules/http2/h2_headers.c
modules/http2/h2_proxy_session.c
modules/http2/h2_stream.c
modules/http2/h2_ws.c
modules/lua/lua_request.c
modules/mappers/mod_rewrite.c
modules/md/md_acme.c
modules/md/md_curl.c
modules/proxy/mod_proxy_ajp.c
modules/proxy/mod_proxy_ftp.c
modules/proxy/mod_proxy_hcheck.c
modules/proxy/mod_proxy_http.c
modules/test/mod_policy.c
server/util_expr_eval.c
test/modules/http1/mod_h1test/mod_h1test.c
test/modules/http2/mod_h2test/mod_h2test.c

index 03376db99587676ed603842922d3b0a782a07b8a..5db96fb4d17bc3632450507a1177700f0f40befa 100644 (file)
@@ -1161,7 +1161,7 @@ struct request_rec {
      * to conclude that no body is there.
      */
     unsigned int body_indeterminate :1;
-    /** Whether a final (status >= 200) RESPONSE BUCKET has been passed down
+    /** Whether a final (status >= HTTP_OK) RESPONSE BUCKET has been passed down
      * the output filters already. Relevant for ap_die().
      *  TODO: compact elsewhere
      */
index c5461d8f624e9ba89352ccddc5814a95ba1ae7dd..757083e40fea11013cadbea73f6ebf2689543964 100644 (file)
@@ -110,7 +110,7 @@ static int authn_cache_post_config(apr_pool_t *pconf, apr_pool_t *plog,
             ap_log_perror(APLOG_MARK, APLOG_CRIT, 0, plog, APLOGNO(02612)
                         "failed to create mod_socache_shmcb socache "
                         "instance: %s", errmsg);
-            return 500;
+            return 500; /* An HTTP status would be a misnomer! */
         }
     }
 
index 37c06e9472710f8eda0505a1aa88b9708682aa73..80205bd27c9954dd97f59cce3653107ffe4a4526 100644 (file)
@@ -1687,10 +1687,10 @@ static apr_status_t cache_invalidate_filter(ap_filter_t *f,
     }
     else {
 
-        if (r->status > 299) {
+        if (r->status >= HTTP_MULTIPLE_CHOICES) {
 
             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02466)
-                    "cache: response status to '%s' method is %d (>299), not invalidating cached entity: %s", r->method, r->status, r->uri);
+                    "cache: response status to '%s' method is %d (>=HTTP_MULTIPLE_CHOICES), not invalidating cached entity: %s", r->method, r->status, r->uri);
 
         }
         else {
index 69aa811a3e72f5d1e6cd0ac0e6c1f5abe312a5ef..42b651f281963a52665a6a31ab4bafb4b352089f 100644 (file)
@@ -1190,7 +1190,7 @@ static int dav_method_put(request_rec *r)
     if ((err = (*resource->hooks->open_stream)(resource, mode,
                                                &stream)) != NULL) {
         int status = err->status ? err->status : HTTP_FORBIDDEN;
-        if (status > 299) {
+        if (status >= HTTP_MULTIPLE_CHOICES) {
             err = dav_push_error(r->pool, status, 0,
                                  apr_psprintf(r->pool,
                                               "Unable to PUT new contents for %s.",
index 8d9be2ad42af09f3d6825ebf24fb3f15ed59cd3b..a481c4dd28f42ec9aa4782e292cc101fd4f100ee 100644 (file)
@@ -1803,7 +1803,7 @@ DAV_DECLARE_NONSTD(void) dav_prop_exec(dav_prop_ctx *ctx);
 DAV_DECLARE_NONSTD(void) dav_prop_commit(dav_prop_ctx *ctx);
 DAV_DECLARE_NONSTD(void) dav_prop_rollback(dav_prop_ctx *ctx);
 
-#define DAV_PROP_CTX_HAS_ERR(dpc)  ((dpc).err && (dpc).err->status >= 300)
+#define DAV_PROP_CTX_HAS_ERR(dpc)  ((dpc).err && (dpc).err->status >= HTTP_MULTIPLE_CHOICES)
 
 
 /* --------------------------------------------------------------------
index 5b5ecf69712a60aac7b4ce92d6fcc68e43124ffb..fbdb84c2676cdc1f69ead1d7d760a27bb5c12937 100644 (file)
@@ -280,7 +280,7 @@ static apr_status_t filter_harness(ap_filter_t *f, apr_bucket_brigade *bb)
     harness_ctx *ctx = f->ctx;
     ap_filter_rec_t *filter = f->frec;
 
-    if (f->r->status != 200
+    if (f->r->status != HTTP_OK
         && !apr_table_get(f->r->subprocess_env, "filter-errordocs")) {
         ap_remove_output_filter(f);
         return ap_pass_brigade(f->next, bb);
index c8571321d1137f38352b628064dc35821e6642f3..9bf08a58e911bb919945c165c82894eb294e1ac7 100644 (file)
@@ -485,7 +485,7 @@ static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb,
 
         location = apr_table_get(r->headers_out, "Location");
 
-        if (location && r->status == 200) {
+        if (location && r->status == HTTP_OK) {
             /* For a redirect whether internal or not, discard any
              * remaining stdout from the script, and log any remaining
              * stderr output, as normal. */
@@ -498,7 +498,7 @@ static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb,
             }
         }
 
-        if (location && location[0] == '/' && r->status == 200) {
+        if (location && location[0] == '/' && r->status == HTTP_OK) {
             /* This redirect needs to be a GET no matter what the original
              * method was.
              */
@@ -514,7 +514,7 @@ static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb,
             ap_internal_redirect_handler(location, r);
             return OK;
         }
-        else if (location && r->status == 200) {
+        else if (location && r->status == HTTP_OK) {
             /* XXX: Note that if a script wants to produce its own Redirect
              * body, it now has to explicitly *say* "Status: 302"
              */
index 8e5f76102ea307e823130a50c6d99558bf349efd..3b042c34c136c8517a566507f30fc8ecf1e61a97 100644 (file)
@@ -1216,7 +1216,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
                     respb = e;
                     resp = respb->data;
                     if (!ctx->final_status
-                        && (resp->status >= 200 || resp->status == HTTP_SWITCHING_PROTOCOLS)) {
+                        && (resp->status >= HTTP_OK || resp->status == HTTP_SWITCHING_PROTOCOLS)) {
                         ctx->final_status = resp->status;
                         ctx->final_header_only = AP_STATUS_IS_HEADER_ONLY(resp->status);
                         bcontent = APR_BUCKET_NEXT(e);
@@ -1899,7 +1899,7 @@ static void h1_append_response_head(request_rec *r,
 }
 
 typedef struct h1_response_ctx {
-    int final_response_sent;    /* strict: a response status >= 200 was sent */
+    int final_response_sent;    /* strict: a response status >= HTTP_OK was sent */
     int discard_body;           /* the response is header only, discard body */
     apr_bucket_brigade *tmpbb;
 } h1_response_ctx;
@@ -1942,7 +1942,7 @@ apr_status_t ap_h1_response_out_filter(ap_filter_t *f,
                 ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
                               "ap_h1_response_out_filter seeing response bucket status=%d",
                               resp->status);
-                if (strict && resp->status < 100) {
+                if (strict && resp->status < HTTP_CONTINUE) {
                     /* error, not a valid http status */
                     ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10386)
                                   "ap_h1_response_out_filter seeing headers "
@@ -1966,8 +1966,8 @@ apr_status_t ap_h1_response_out_filter(ap_filter_t *f,
                      */
                     const char *proto = AP_SERVER_PROTOCOL;
 
-                    ctx->final_response_sent = (resp->status >= 200)
-                        || (!strict && resp->status < 100);
+                    ctx->final_response_sent = (resp->status >= HTTP_OK)
+                        || (!strict && resp->status < HTTP_CONTINUE);
                     ctx->discard_body = ctx->final_response_sent &&
                         (r->header_only || AP_STATUS_IS_HEADER_ONLY(resp->status));
 
index 5a9019aa0cfba170a8b829dd2ea6191f185c8077..3ca6114d470990590723c6f9391b2db5e0027f33 100644 (file)
@@ -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;
index 523a941450b88f6286f806a3ac551daf0b035eb5..7874cae138cfae001842dfd4edf8470dacb4f4cd 100644 (file)
@@ -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);
                 }
index d9b3fd09b064bdd659b1c7a2640fa2a4a3e52914..c21a360bbe9c62ed30fd150f9749e49157eb0b80 100644 (file)
@@ -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 */
index 166b6468f1da9cae6e0b865757c862052b352ec3..f1634eec9b63a9e35bdcd1fcb80c6a2db57a29b2 100644 (file)
@@ -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, 
index f0e671ca5d660a915758431dd91c41c5124f2ef7..653af3fb18cfb0159b56e9037f97cc02cd872771 100644 (file)
@@ -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;
     }
 
index 4643660f3069a3a537c59af986bb94bbd8201450..9e3d5087673fb039caca8d5434d2f3870c5e3cc8 100644 (file)
@@ -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",
index 15605cd76c1b7519547b6fe2d90a939a033f849f..587b690c6fa8d3cb8106edc87b5d1d22502e19dd 100644 (file)
@@ -2209,7 +2209,7 @@ static int lua_websocket_greet(lua_State *L)
         if (encoded_len) {
             encoded = apr_palloc(r->pool, encoded_len);
             encoded_len = apr_base64_encode(encoded, (char*) digest, APR_SHA1_DIGESTSIZE);
-            r->status = 101;
+            r->status = HTTP_SWITCHING_PROTOCOLS;
             apr_table_setn(r->headers_out, "Upgrade", "websocket");
             apr_table_setn(r->headers_out, "Connection", "Upgrade");
             apr_table_setn(r->headers_out, "Sec-WebSocket-Accept", encoded);
@@ -2542,7 +2542,7 @@ APLUA_REQ_TRACE(6)
 APLUA_REQ_TRACE(7)
 APLUA_REQ_TRACE(8)
 
-/* handle r.status = 201 */
+/* handle r.status = HTTP_CREATED */
 static int req_newindex(lua_State *L)
 {
     const char *key;
index 75b41110b31b01635bf67373d9fc441afebf716f..346c504f9a655c4a94a7c1dcab212d1855c6b916 100644 (file)
@@ -4201,7 +4201,7 @@ static cond_return_type apply_rewrite_cond(rewritecond_entry *p, rewrite_ctx *ct
     case CONDPAT_LU_URL:
         if (*input && subreq_ok(r)) {
             rsub = ap_sub_req_lookup_uri(input, r, NULL);
-            if (rsub->status < 400) {
+            if (rsub->status < HTTP_BAD_REQUEST) {
                 rc = COND_RC_MATCH;
             }
             rewritelog(r, 5, NULL, "RewriteCond URI (-U check: "
@@ -4218,7 +4218,7 @@ static cond_return_type apply_rewrite_cond(rewritecond_entry *p, rewrite_ctx *ct
                 return COND_RC_STATUS_SET;
             }
             rsub = ap_sub_req_lookup_file(input, r, NULL);
-            if (rsub->status < 300 &&
+            if (rsub->status < HTTP_MULTIPLE_CHOICES &&
                 /* double-check that file exists since default result is 200 */
                 apr_stat(&sb, rsub->filename, APR_FINFO_MIN,
                          r->pool) == APR_SUCCESS) {
index a62438da4df6bf0a8dd1982e89d0d1dfda8d936b..7c876c62c9e640039717e427601ddd37fc4457bf 100644 (file)
@@ -23,6 +23,8 @@
 #include <apr_hash.h>
 #include <apr_uri.h>
 
+#include <httpd.h>
+
 #include "md.h"
 #include "md_crypt.h"
 #include "md_json.h"
@@ -74,10 +76,10 @@ static acme_problem_status_t Problems[] = {
 static apr_status_t problem_status_get(const char *type) {
     size_t i;
 
-    if (strstr(type, "urn:ietf:params:") == type) {
+    if (ap_strstr_c(type, "urn:ietf:params:") == type) {
         type += strlen("urn:ietf:params:");
     }
-    else if (strstr(type, "urn:") == type) {
+    else if (ap_strstr_c(type, "urn:") == type) {
         type += strlen("urn:");
     }
      
@@ -93,10 +95,10 @@ int md_acme_problem_is_input_related(const char *problem) {
     size_t i;
 
     if (!problem) return 0;
-    if (strstr(problem, "urn:ietf:params:") == problem) {
+    if (ap_strstr_c(problem, "urn:ietf:params:") == problem) {
         problem += strlen("urn:ietf:params:");
     }
-    else if (strstr(problem, "urn:") == problem) {
+    else if (ap_strstr_c(problem, "urn:") == problem) {
         problem += strlen("urn:");
     }
 
@@ -205,12 +207,12 @@ static apr_status_t inspect_problem(md_acme_req_t *req, const md_http_response_t
     }
     
     switch (res->status) {
-        case 400:
+        case HTTP_BAD_REQUEST:
             return APR_EINVAL;
-        case 401: /* sectigo returns this instead of 403 */
-        case 403:
+        case HTTP_UNAUTHORIZED: /* sectigo returns this instead of 403 */
+        case HTTP_FORBIDDEN:
             return APR_EACCES;
-        case 404:
+        case HTTP_NOT_FOUND:
             return APR_ENOENT;
         default:
             md_log_perror(MD_LOG_MARK, MD_LOG_WARNING, 0, req->p,
@@ -282,7 +284,7 @@ static apr_status_t on_response(const md_http_response_t *res, void *data)
     req_update_nonce(req->acme, res->headers);
     
     md_log_perror(MD_LOG_MARK, MD_LOG_TRACE1, rv, req->p, "response: %d", res->status);
-    if (res->status >= 200 && res->status < 300) {
+    if (ap_is_HTTP_SUCCESS(res->status)) {
         int processed = 0;
         
         if (req->on_json) {
@@ -687,7 +689,7 @@ static apr_status_t update_directory(const md_http_response_t *res, void *data)
     const char *s;
     
     md_log_perror(MD_LOG_MARK, MD_LOG_TRACE1, 0, req->pool, "directory lookup response: %d", res->status);
-    if (res->status == 503) {
+    if (res->status == HTTP_SERVICE_UNAVAILABLE) {
         md_result_printf(result, APR_EAGAIN,
             "The ACME server at <%s> reports that Service is Unavailable (503). This "
             "may happen during maintenance for short periods of time.", acme->url); 
@@ -695,7 +697,7 @@ static apr_status_t update_directory(const md_http_response_t *res, void *data)
         rv = result->status;
         goto leave;
     }
-    else if (res->status < 200 || res->status >= 300) {
+    else if (res->status < HTTP_OK || res->status >= HTTP_MULTIPLE_CHOICES) {
         md_result_printf(result, APR_EAGAIN,
             "The ACME server at <%s> responded with HTTP status %d. This "
             "is unusual. Please verify that the URL is correct and that you can indeed "
index fac2ab8ec911f57ba74bc11e10be2c0a0f3ae5c2..2484faf51a1f1c5048c108c8b3e284c3d7d61fb9 100644 (file)
@@ -22,6 +22,8 @@
 #include <apr_strings.h>
 #include <apr_buckets.h>
 
+#include <httpd.h>
+
 #include "md.h"
 #include "md_http.h"
 #include "md_log.h"
@@ -168,8 +170,8 @@ static int curlify_headers(void *baton, const char *key, const char *value)
     curlify_hdrs_ctx *ctx = baton;
     const char *s;
     
-    if (strchr(key, '\r') || strchr(key, '\n')
-        || strchr(value, '\r') || strchr(value, '\n')) {
+    if (ap_strchr_c(key, '\r') || ap_strchr_c(key, '\n')
+        || ap_strchr_c(value, '\r') || ap_strchr_c(value, '\n')) {
         ctx->rv = APR_EINVAL;
         return 0;
     }
@@ -273,7 +275,7 @@ static apr_status_t internals_setup(md_http_request_t *req)
         
     internals->response = apr_pcalloc(req->pool, sizeof(md_http_response_t));
     internals->response->req = req;
-    internals->response->status = 400;
+    internals->response->status = HTTP_BAD_REQUEST;
     internals->response->headers = apr_table_make(req->pool, 5);
     internals->response->body = apr_brigade_create(req->pool, req->bucket_alloc);
     
index 9c6573b59ac134e3da15a67b72f9f92809bd7f55..e269ae31d96101d9c166204cec7f85bfd96700d2 100644 (file)
@@ -490,7 +490,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
                 if (status != APR_SUCCESS) {
                     backend_failed = 1;
                 }
-                else if ((r->status == 401) && conf->error_override) {
+                else if ((r->status == HTTP_UNAUTHORIZED) && conf->error_override) {
                     const char *buf;
                     const char *wa = "WWW-Authenticate";
                     if ((buf = apr_table_get(r->headers_out, wa))) {
index f33360efa51287597786cbcd4d7a6c57da4d8fc2..f8833560efda5c844f44448593d8a946ba898407 100644 (file)
@@ -1870,7 +1870,7 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
     }
 
     r->status = HTTP_OK;
-    r->status_line = "200 OK";
+    r->status_line = ap_get_status_line(r->status);
 
     apr_rfc822_date(dates, r->request_time);
     apr_table_setn(r->headers_out, "Date", dates);
index 92e1bced286d3b104581f9122503e8a99553d399..7b8e336fead41dcfebcd03d218571db57e7960e8 100644 (file)
@@ -906,7 +906,7 @@ static apr_status_t hc_check_http(baton_t *baton, apr_thread_t *thread)
                          hc->s->name, worker->s->name);
             status = !OK;
         }
-    } else if (r->status < 200 || r->status > 399) {
+    } else if (r->status < HTTP_OK || r->status >= HTTP_BAD_REQUEST) {
         ap_log_error(APLOG_MARK, APLOG_TRACE2, 0, ctx->s,
                      "Response status %i for %s (%s): failed", r->status,
                      hc->s->name, worker->s->name);
index 98387d62b3f43d1b7c1591de90bba49e576e3cf5..7bdb0f6699ba144c40988fbad16f5fa6e0ad694f 100644 (file)
@@ -1413,7 +1413,7 @@ int ap_proxy_http_process_response(proxy_http_req_t *req)
         } else {
             /* an http/0.9 response */
             backasswards = 1;
-            r->status = proxy_status = 200;
+            r->status = proxy_status = HTTP_OK;
             r->status_line = "200 OK";
             backend->close = 1;
         }
index 841b1b16bdb699a4afecda8369679666628eb7de..1051209db4cc2f4c45aea8cf75a117c7e6013c34 100644 (file)
@@ -258,7 +258,7 @@ static apr_status_t policy_length_out_filter(ap_filter_t *f,
             &policy_module);
     policy_result result = check_enabled(r, conf, conf->length_action);
 
-    if (result != policy_ignore && r->status >= 200 && r->status < 300
+    if (result != policy_ignore && ap_is_HTTP_SUCCESS(r->status)
             && r->status != HTTP_NO_CONTENT) {
 
         if (!apr_table_get(r->headers_out, "Content-Length")) {
index f9db28e70442cf4c86feabc404a4e16375374ed4..603ade679cc9b0240c8a4b04a8e7fd5a76a18930 100644 (file)
@@ -1650,7 +1650,7 @@ static int op_url_subr(ap_expr_eval_ctx_t *ctx, const void *data, const char *ar
         return FALSE;
 
     rsub = ap_sub_req_lookup_uri(arg, r, NULL);
-    if (rsub->status < 400) {
+    if (rsub->status < HTTP_BAD_REQUEST) {
             rc = TRUE;
     }
     expr_eval_log(ctx, APLOG_TRACE5,
@@ -1672,7 +1672,7 @@ static int op_file_subr(ap_expr_eval_ctx_t *ctx, const void *data, const char *a
         return FALSE;
     }
     rsub = ap_sub_req_lookup_file(arg, r, NULL);
-    if (rsub->status < 300 &&
+    if (rsub->status < HTTP_MULTIPLE_CHOICES &&
         /* double-check that file exists since default result is 200 */
         apr_stat(&sb, rsub->filename, APR_FINFO_MIN, ctx->p) == APR_SUCCESS) {
         rc = TRUE;
index cbd87b5b6c197ced9f5a4ea505b2585b2bc6d47d..8c5ac4a42f96b7358124ecb281a44e0128ffa47c 100644 (file)
@@ -60,7 +60,7 @@ static int h1test_echo_handler(request_rec *r)
     }
 
     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "echo_handler: processing request");
-    r->status = 200;
+    r->status = HTTP_OK;
     r->clength = -1;
     r->chunked = 1;
     ct = apr_table_get(r->headers_in, "content-type");
index f20b9547e7045c87ac587fb2a2452143806b2ac2..59a606b64490440e299594b2e773a29ab767b38b 100644 (file)
@@ -186,7 +186,7 @@ static int h2test_echo_handler(request_rec *r)
     }
 
     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "echo_handler: processing request");
-    r->status = 200;
+    r->status = HTTP_OK;
     r->clength = -1;
     r->chunked = 1;
     apr_table_unset(r->headers_out, "Content-Length");
@@ -290,7 +290,7 @@ static int h2test_delay_handler(request_rec *r)
 
     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "delay_handler: processing request, %ds delay",
                   (int)apr_time_sec(delay));
-    r->status = 200;
+    r->status = HTTP_OK;
     r->clength = -1;
     r->chunked = 1;
     apr_table_unset(r->headers_out, "Content-Length");
@@ -373,7 +373,7 @@ static int h2test_trailer_handler(request_rec *r)
 
     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "trailer_handler: processing request, %d body length",
                   body_len);
-    r->status = 200;
+    r->status = HTTP_OK;
     r->clength = body_len;
     ap_set_content_length(r, body_len);
 
@@ -437,7 +437,7 @@ static int h2test_error_handler(request_rec *r)
     long l;
     apr_time_t delay = 0, body_delay = 0;
     apr_array_header_t *args = NULL;
-    int http_status = 200;
+    int http_status = HTTP_OK;
     apr_status_t error = APR_SUCCESS, body_error = APR_SUCCESS;
 
     if (strcmp(r->handler, "h2test-error")) {