ajp_header.c revision 3e13c3c3e6517a04c8c20ffb8e62aadb3b13f8df
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* Licensed to the Apache Software Foundation (ASF) under one or more
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * contributor license agreements. See the NOTICE file distributed with
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * this work for additional information regarding copyright ownership.
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * The ASF licenses this file to You under the Apache License, Version 2.0
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * (the "License"); you may not use this file except in compliance with
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * the License. You may obtain a copy of the License at
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * Unless required by applicable law or agreed to in writing, software
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * distributed under the License is distributed on an "AS IS" BASIS,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * See the License for the specific language governing permissions and
2e545ce2450a9953665f701bb05350f0d3f26275nd * limitations under the License.
a78048ccbdb6256da15e6b0e7e95355e480c2301ndstatic const char *response_trans_headers[] = {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Content-Type",
3f08db06526d6901aa08c110b5bc7dde6bc39905nd "Content-Language",
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Content-Length",
befb6758d5618c60f29b19f9a7eb75ab993511dcjim "Last-Modified",
aee1f193a276866212922ae5072e3014db28582frpluem "Location",
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung "Set-Cookie",
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Set-Cookie2",
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem "Servlet-Engine",
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "WWW-Authenticate"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const char *p = header_name;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd int i = 0;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd /* ACCEPT-LANGUAGE is the longest header
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * that is of interest.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd while (*p)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd switch (header[0]) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd /* NOTREACHED */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* Apache method number to SC methods transform table */
a78048ccbdb6256da15e6b0e7e95355e480c2301ndstatic const unsigned char sc_for_req_method_table[] = {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd 0, /* M_DELETE */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd 0, /* M_PATCH */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd 0 /* M_INVALID */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd else if (r->header_only) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * Message structure
a78048ccbdb6256da15e6b0e7e95355e480c2301nd request_prefix (1) (byte)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd method (byte)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd protocol (string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd req_uri (string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd remote_addr (string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd remote_host (string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd server_name (string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd server_port (short)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd is_ssl (boolean)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd num_headers (short)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd num_headers*(req_header_name header_value)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?context (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?servlet_path (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?remote_user (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?auth_type (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?query_string (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?jvm_route (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?ssl_cert (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?ssl_cipher (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?ssl_session (byte)(string)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?ssl_key_size (byte)(int) via JkOptions +ForwardKeySize
a78048ccbdb6256da15e6b0e7e95355e480c2301nd request_terminator (byte)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ?body content_length*(var binary)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Into ajp_marshal_into_msgb");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd if ((method = sc_for_req_method_by_id(r)) == UNKNOWN_METHOD) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb - No such method %s",
a78048ccbdb6256da15e6b0e7e95355e480c2301nd is_ssl = (apr_byte_t) ap_proxy_conn_is_https(r->connection);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const apr_array_header_t *t = apr_table_elts(r->headers_in);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd remote_host = (char *)ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_HOST, NULL);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd if (ajp_msg_append_uint8(msg, CMD_AJP13_FORWARD_REQUEST) ||
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ajp_msg_append_uint16(msg, (apr_uint16_t)r->connection->local_addr->port) ||
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ajp_msg_append_uint16(msg, (apr_uint16_t) num_headers)) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the message begining");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd for (i = 0 ; i < num_headers ; i++) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const apr_array_header_t *t = apr_table_elts(r->headers_in);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const apr_table_entry_t *elts = (apr_table_entry_t *)t->elts;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd if ((sc = sc_for_req_header(elts[i].key)) != UNKNOWN_METHOD) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the header name");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the header name");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the header value");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: Header[%d] [%s] = [%s]",
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* XXXX need to figure out how to do this
a78048ccbdb6256da15e6b0e7e95355e480c2301nd if (s->secret) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd if (ajp_msg_append_uint8(msg, SC_A_SECRET) ||
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ajp_msg_append_string(msg, s->secret)) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error ajp_marshal_into_msgb - "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending secret");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd return APR_EGENERAL;
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the remote user");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the auth type");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd /* XXXX ebcdic (args converted?) */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the query string");
d972e4a0688f66b1402473dd9dacfecefa2132a8rbowen if ((session_route = apr_table_get(r->notes, "session-route"))) {
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "ajp_marshal_into_msgb: "
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "Error appending the jvm route");
befb6758d5618c60f29b19f9a7eb75ab993511dcjim/* XXX: Is the subprocess_env a right place?
aee1f193a276866212922ae5072e3014db28582frpluem * <Location /examples>
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * ProxyPass ajp://remote:8009/servlets-examples
727872d18412fc021f03969b8641810d8896820bhumbedooh * SetEnv SSL_SESSION_ID CUSTOM_SSL_SESSION_ID
0d0ba3a410038e179b695446bb149cce6264e0abnd * </Location>
0d0ba3a410038e179b695446bb149cce6264e0abnd * Only lookup SSL variables if we are currently running HTTPS.
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh * Furthermore ensure that only variables get set in the AJP message
727872d18412fc021f03969b8641810d8896820bhumbedooh * that are not NULL and not empty.
0d0ba3a410038e179b695446bb149cce6264e0abnd if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
0d0ba3a410038e179b695446bb149cce6264e0abnd "ajp_marshal_into_msgb: "
0d0ba3a410038e179b695446bb149cce6264e0abnd "Error appending the SSL certificates");
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
return AJP_EOVERFLOW;
&& envvar[0]) {
return AJP_EOVERFLOW;
&& envvar[0]) {
return APR_EGENERAL;
return AJP_EOVERFLOW;
return AJP_EOVERFLOW;
return AJP_EOVERFLOW;
return APR_SUCCESS;
request_rec *r,
const char *ptr;
return rc;
num_headers = 0;
for(i = 0 ; i < (int) num_headers ; i++) {
const char *stringname;
const char *value;
return rc;
name);
return AJP_EBAD_HEADER;
name = 0;
return rc;
return rc;
return APR_SUCCESS;
request_rec *r,
return rc;
return rc;
return rc;
return APR_SUCCESS;
request_rec *r,
if (*msg) {
return rc;
return rc;
return rc;
return APR_SUCCESS;
return (int) result;
return rc;
return AJP_EBAD_HEADER;
return rc;
return AJP_EBAD_HEADER;
return rc;
return AJP_EBAD_HEADER;
return APR_SUCCESS;
return rc;
return AJP_EBAD_HEADER;
return rc;
return APR_SUCCESS;