* 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
*/
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! */
}
}
}
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 {
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.",
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)
/* --------------------------------------------------------------------
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);
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. */
}
}
- 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.
*/
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"
*/
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);
}
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;
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 "
*/
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));
{
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;
}
}
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;
{
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.
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,
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);
}
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);
int h2_headers_are_final_response(h2_headers *headers)
{
- return headers->status >= 200;
+ return headers->status >= HTTP_OK;
}
#endif /* !AP_HAS_RESPONSE_BUCKETS */
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;
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)) {
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;
}
}
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,
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 {
goto cleanup;
}
- if (resp->status < 100) {
+ if (resp->status < HTTP_CONTINUE) {
h2_stream_rst(stream, resp->status);
goto cleanup;
}
&& !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 */
}
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;
}
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",
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);
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;
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: "
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) {
#include <apr_hash.h>
#include <apr_uri.h>
+#include <httpd.h>
+
#include "md.h"
#include "md_crypt.h"
#include "md_json.h"
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:");
}
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:");
}
}
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,
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) {
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);
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 "
#include <apr_strings.h>
#include <apr_buckets.h>
+#include <httpd.h>
+
#include "md.h"
#include "md_http.h"
#include "md_log.h"
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;
}
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);
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))) {
}
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);
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);
} 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;
}
&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")) {
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,
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;
}
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");
}
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");
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");
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);
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")) {