MCPcopy Create free account
hub / github.com/apache/httpd / ap_response_code_string

Function ap_response_code_string

server/core.c:878–921  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876 */
877
878char *ap_response_code_string(request_rec *r, int error_index)
879{
880 core_dir_config *dirconf;
881 core_request_config *reqconf = ap_get_core_module_config(r->request_config);
882 const char *err;
883 const char *response;
884 ap_expr_info_t *expr;
885
886 /* check for string registered via ap_custom_response() first */
887 if (reqconf->response_code_strings != NULL
888 && reqconf->response_code_strings[error_index] != NULL) {
889 return reqconf->response_code_strings[error_index];
890 }
891
892 /* check for string specified via ErrorDocument */
893 dirconf = ap_get_core_module_config(r->per_dir_config);
894
895 if (!dirconf->response_code_exprs) {
896 return NULL;
897 }
898
899 expr = apr_hash_get(dirconf->response_code_exprs, &error_index,
900 sizeof(error_index));
901 if (!expr) {
902 return NULL;
903 }
904
905 /* special token to indicate revert back to default */
906 if ((char *) expr == &errordocument_default) {
907 return NULL;
908 }
909
910 err = NULL;
911 response = ap_expr_str_exec(r, expr, &err);
912 if (err) {
913 ap_log_rerror(
914 APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02841) "core: ErrorDocument: can't "
915 "evaluate require expression: %s", err);
916 return NULL;
917 }
918
919 /* alas, duplication required as we return not-const */
920 return apr_pstrdup(r->pool, response);
921}
922
923
924/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */

Callers 2

ap_send_error_responseFunction · 0.85
ap_die_rFunction · 0.85

Calls 2

ap_expr_str_execFunction · 0.85

Tested by

no test coverage detected