mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Return 'real' error status codes instead APR_EGENERAL.
The return status code will be used to determine wether the message is invalid or the remote host failed processing the request. This is needed to mark the worker as in error state in case it is member of load balancer. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@160668 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -103,6 +103,9 @@
|
|||||||
#define AJP_EBAD_MESSAGE (APR_OS_START_USERERR + 8)
|
#define AJP_EBAD_MESSAGE (APR_OS_START_USERERR + 8)
|
||||||
/** Cant log via AJP14 */
|
/** Cant log via AJP14 */
|
||||||
#define AJP_ELOGFAIL (APR_OS_START_USERERR + 9)
|
#define AJP_ELOGFAIL (APR_OS_START_USERERR + 9)
|
||||||
|
/** Bad request method */
|
||||||
|
#define AJP_EBAD_METHOD (APR_OS_START_USERERR + 10)
|
||||||
|
|
||||||
|
|
||||||
/** A structure that represents ajp message */
|
/** A structure that represents ajp message */
|
||||||
typedef struct ajp_msg ajp_msg_t;
|
typedef struct ajp_msg ajp_msg_t;
|
||||||
|
@@ -220,9 +220,9 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
|
|
||||||
if ((method = sc_for_req_method_by_id(r->method_number)) == UNKNOWN_METHOD) {
|
if ((method = sc_for_req_method_by_id(r->method_number)) == UNKNOWN_METHOD) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - No such method %s",
|
"ajp_marshal_into_msgb - No such method %s",
|
||||||
r->method);
|
r->method);
|
||||||
return APR_EGENERAL;
|
return AJP_EBAD_METHOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXXX need something */
|
/* XXXX need something */
|
||||||
@@ -249,7 +249,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
ajp_msg_append_uint16(msg, (apr_uint16_t) num_headers)) {
|
ajp_msg_append_uint16(msg, (apr_uint16_t) num_headers)) {
|
||||||
|
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the message begining");
|
"Error appending the message begining");
|
||||||
return APR_EGENERAL;
|
return APR_EGENERAL;
|
||||||
}
|
}
|
||||||
@@ -262,25 +262,25 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
if ((sc = sc_for_req_header(elts[i].key)) != UNKNOWN_METHOD) {
|
if ((sc = sc_for_req_header(elts[i].key)) != UNKNOWN_METHOD) {
|
||||||
if (ajp_msg_append_uint16(msg, (apr_uint16_t)sc)) {
|
if (ajp_msg_append_uint16(msg, (apr_uint16_t)sc)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the header name");
|
"Error appending the header name");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (ajp_msg_append_string(msg, elts[i].key)) {
|
if (ajp_msg_append_string(msg, elts[i].key)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the header name");
|
"Error appending the header name");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ajp_msg_append_string(msg, elts[i].val)) {
|
if (ajp_msg_append_string(msg, elts[i].val)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the header value");
|
"Error appending the header value");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
|
||||||
"ajp_marshal_into_msgb: Header[%d] [%s] = [%s]",
|
"ajp_marshal_into_msgb: Header[%d] [%s] = [%s]",
|
||||||
@@ -303,18 +303,18 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
if (ajp_msg_append_uint8(msg, SC_A_REMOTE_USER) ||
|
if (ajp_msg_append_uint8(msg, SC_A_REMOTE_USER) ||
|
||||||
ajp_msg_append_string(msg, r->user)) {
|
ajp_msg_append_string(msg, r->user)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the remote user");
|
"Error appending the remote user");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (r->ap_auth_type) {
|
if (r->ap_auth_type) {
|
||||||
if (ajp_msg_append_uint8(msg, SC_A_AUTH_TYPE) ||
|
if (ajp_msg_append_uint8(msg, SC_A_AUTH_TYPE) ||
|
||||||
ajp_msg_append_string(msg, r->ap_auth_type)) {
|
ajp_msg_append_string(msg, r->ap_auth_type)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the auth type");
|
"Error appending the auth type");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* XXXX ebcdic (args converted?) */
|
/* XXXX ebcdic (args converted?) */
|
||||||
@@ -322,18 +322,18 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
if (ajp_msg_append_uint8(msg, SC_A_QUERY_STRING) ||
|
if (ajp_msg_append_uint8(msg, SC_A_QUERY_STRING) ||
|
||||||
ajp_msg_append_string(msg, uri->query)) {
|
ajp_msg_append_string(msg, uri->query)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the query string");
|
"Error appending the query string");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((session_route = apr_table_get(r->notes, "session-route"))) {
|
if ((session_route = apr_table_get(r->notes, "session-route"))) {
|
||||||
if (ajp_msg_append_uint8(msg, SC_A_JVM_ROUTE) ||
|
if (ajp_msg_append_uint8(msg, SC_A_JVM_ROUTE) ||
|
||||||
ajp_msg_append_string(msg, session_route)) {
|
ajp_msg_append_string(msg, session_route)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the jvm route");
|
"Error appending the jvm route");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* XXX: Is the subprocess_env a right place?
|
/* XXX: Is the subprocess_env a right place?
|
||||||
@@ -347,9 +347,9 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
if (ajp_msg_append_uint8(msg, SC_A_SSL_CERT) ||
|
if (ajp_msg_append_uint8(msg, SC_A_SSL_CERT) ||
|
||||||
ajp_msg_append_string(msg, envvar)) {
|
ajp_msg_append_string(msg, envvar)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the SSL certificates");
|
"Error appending the SSL certificates");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,9 +358,9 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
if (ajp_msg_append_uint8(msg, SC_A_SSL_CIPHER) ||
|
if (ajp_msg_append_uint8(msg, SC_A_SSL_CIPHER) ||
|
||||||
ajp_msg_append_string(msg, envvar)) {
|
ajp_msg_append_string(msg, envvar)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the SSL ciphers");
|
"Error appending the SSL ciphers");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,9 +369,9 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
if (ajp_msg_append_uint8(msg, SC_A_SSL_SESSION) ||
|
if (ajp_msg_append_uint8(msg, SC_A_SSL_SESSION) ||
|
||||||
ajp_msg_append_string(msg, envvar)) {
|
ajp_msg_append_string(msg, envvar)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the SSL session");
|
"Error appending the SSL session");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,23 +400,23 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
|
|||||||
ajp_msg_append_string(msg, elts[i].key + 4) ||
|
ajp_msg_append_string(msg, elts[i].key + 4) ||
|
||||||
ajp_msg_append_string(msg, elts[i].val)) {
|
ajp_msg_append_string(msg, elts[i].val)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending attribute %s=%s",
|
"Error appending attribute %s=%s",
|
||||||
elts[i].key, elts[i].val);
|
elts[i].key, elts[i].val);
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ajp_msg_append_uint8(msg, SC_A_ARE_DONE)) {
|
if (ajp_msg_append_uint8(msg, SC_A_ARE_DONE)) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_marshal_into_msgb - "
|
"ajp_marshal_into_msgb: "
|
||||||
"Error appending the message end");
|
"Error appending the message end");
|
||||||
return APR_EGENERAL;
|
return AJP_EOVERFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
|
||||||
"ajp_marshal_into_msgb - Done");
|
"ajp_marshal_into_msgb: Done");
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,8 +460,8 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
|
|||||||
|
|
||||||
if (rc != APR_SUCCESS) {
|
if (rc != APR_SUCCESS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_unmarshal_response - Null status");
|
"ajp_unmarshal_response: Null status");
|
||||||
return APR_EGENERAL;
|
return rc;
|
||||||
}
|
}
|
||||||
r->status = status;
|
r->status = status;
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
|
|||||||
const char *value;
|
const char *value;
|
||||||
rc = ajp_msg_peek_uint16(msg, &name);
|
rc = ajp_msg_peek_uint16(msg, &name);
|
||||||
if (rc != APR_SUCCESS) {
|
if (rc != APR_SUCCESS) {
|
||||||
return APR_EGENERAL;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((name & 0XFF00) == 0XA000) {
|
if ((name & 0XFF00) == 0XA000) {
|
||||||
@@ -504,19 +504,19 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
|
|||||||
stringname = long_res_header_for_sc(name);
|
stringname = long_res_header_for_sc(name);
|
||||||
if (stringname == NULL) {
|
if (stringname == NULL) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_unmarshal_response - "
|
"ajp_unmarshal_response: "
|
||||||
"No such sc (%08x)",
|
"No such sc (%08x)",
|
||||||
name);
|
name);
|
||||||
return APR_EGENERAL;
|
return AJP_EBAD_HEADER;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
name = 0;
|
name = 0;
|
||||||
rc = ajp_msg_get_string(msg, &stringname);
|
rc = ajp_msg_get_string(msg, &stringname);
|
||||||
if (rc != APR_SUCCESS) {
|
if (rc != APR_SUCCESS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_unmarshal_response - "
|
"ajp_unmarshal_response: "
|
||||||
"Null header name");
|
"Null header name");
|
||||||
return APR_EGENERAL;
|
return rc;
|
||||||
}
|
}
|
||||||
#if defined(AS400) || defined(_OSD_POSIX)
|
#if defined(AS400) || defined(_OSD_POSIX)
|
||||||
ap_xlate_proto_from_ascii(stringname, strlen(stringname));
|
ap_xlate_proto_from_ascii(stringname, strlen(stringname));
|
||||||
@@ -526,9 +526,9 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
|
|||||||
rc = ajp_msg_get_string(msg, &value);
|
rc = ajp_msg_get_string(msg, &value);
|
||||||
if (rc != APR_SUCCESS) {
|
if (rc != APR_SUCCESS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"Error ajp_unmarshal_response - "
|
"ajp_unmarshal_response: "
|
||||||
"Null header value");
|
"Null header value");
|
||||||
return APR_EGENERAL;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set-Cookie need additional processing */
|
/* Set-Cookie need additional processing */
|
||||||
@@ -655,7 +655,7 @@ apr_status_t ajp_parse_header(request_rec *r, proxy_server_conf *conf,
|
|||||||
if (result != CMD_AJP13_SEND_HEADERS) {
|
if (result != CMD_AJP13_SEND_HEADERS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"ajp_parse_headers: wrong type %02x expecting 0x04", result);
|
"ajp_parse_headers: wrong type %02x expecting 0x04", result);
|
||||||
return APR_EGENERAL;
|
return AJP_EBAD_HEADER;
|
||||||
}
|
}
|
||||||
return ajp_unmarshal_response(msg, r, conf);
|
return ajp_unmarshal_response(msg, r, conf);
|
||||||
}
|
}
|
||||||
@@ -676,11 +676,11 @@ apr_status_t ajp_parse_data(request_rec *r, ajp_msg_t *msg,
|
|||||||
if (result != CMD_AJP13_SEND_BODY_CHUNK) {
|
if (result != CMD_AJP13_SEND_BODY_CHUNK) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
|
||||||
"ajp_parse_data: wrong type %02x expecting 0x03", result);
|
"ajp_parse_data: wrong type %02x expecting 0x03", result);
|
||||||
return APR_EGENERAL;
|
return AJP_EBAD_HEADER;
|
||||||
}
|
}
|
||||||
rc = ajp_msg_get_uint16(msg, len);
|
rc = ajp_msg_get_uint16(msg, len);
|
||||||
if (rc != APR_SUCCESS) {
|
if (rc != APR_SUCCESS) {
|
||||||
return APR_EGENERAL;
|
return rc;
|
||||||
}
|
}
|
||||||
*ptr = (char *)&(msg->buf[msg->pos]);
|
*ptr = (char *)&(msg->buf[msg->pos]);
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
|
Reference in New Issue
Block a user