1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "ajp_header.h"
20 APLOG_USE_MODULE(proxy_ajp);
22 static const char *response_trans_headers[] = {
36 static const char *long_res_header_for_sc(int sc)
38 const char *rc = NULL;
40 if(sc <= SC_RES_HEADERS_NUM && sc > 0) {
41 rc = response_trans_headers[sc - 1];
47 #define UNKNOWN_METHOD (-1)
49 static int sc_for_req_header(const char *header_name)
52 apr_size_t len = strlen(header_name);
53 const char *p = header_name;
56 /* ACCEPT-LANGUAGE is the longest header
57 * that is of interest.
59 if (len < 4 || len > 15)
60 return UNKNOWN_METHOD;
63 header[i++] = apr_toupper(*p++);
69 if (memcmp(p, "CCEPT", 5) == 0) {
72 else if (header[6] == '-') {
74 if (strcmp(p, "CHARSET") == 0)
75 return SC_ACCEPT_CHARSET;
76 else if (strcmp(p, "ENCODING") == 0)
77 return SC_ACCEPT_ENCODING;
78 else if (strcmp(p, "LANGUAGE") == 0)
79 return SC_ACCEPT_LANGUAGE;
81 return UNKNOWN_METHOD;
84 return UNKNOWN_METHOD;
86 else if (strcmp(p, "UTHORIZATION") == 0)
87 return SC_AUTHORIZATION;
89 return UNKNOWN_METHOD;
92 if(strcmp(p, "OOKIE2") == 0)
94 else if (strcmp(p, "OOKIE") == 0)
96 else if(strcmp(p, "ONNECTION") == 0)
98 else if(strcmp(p, "ONTENT-TYPE") == 0)
99 return SC_CONTENT_TYPE;
100 else if(strcmp(p, "ONTENT-LENGTH") == 0)
101 return SC_CONTENT_LENGTH;
103 return UNKNOWN_METHOD;
106 if(strcmp(p, "OST") == 0)
109 return UNKNOWN_METHOD;
112 if(strcmp(p, "RAGMA") == 0)
115 return UNKNOWN_METHOD;
118 if(strcmp(p, "EFERER") == 0)
121 return UNKNOWN_METHOD;
124 if(strcmp(p, "SER-AGENT") == 0)
125 return SC_USER_AGENT;
127 return UNKNOWN_METHOD;
130 return UNKNOWN_METHOD;
136 /* Apache method number to SC methods transform table */
137 static const unsigned char sc_for_req_method_table[] = {
153 SC_M_VERSION_CONTROL,
162 SC_M_BASELINE_CONTROL,
167 static int sc_for_req_method_by_id(request_rec *r)
169 int method_id = r->method_number;
170 if (method_id < 0 || method_id > M_INVALID) {
171 return UNKNOWN_METHOD;
173 else if (r->header_only) {
177 return sc_for_req_method_table[method_id] ?
178 sc_for_req_method_table[method_id] : UNKNOWN_METHOD;
186 AJPV13_REQUEST/AJPV14_REQUEST=
187 request_prefix (1) (byte)
197 num_headers*(req_header_name header_value)
199 ?context (byte)(string)
200 ?servlet_path (byte)(string)
201 ?remote_user (byte)(string)
202 ?auth_type (byte)(string)
203 ?query_string (byte)(string)
204 ?jvm_route (byte)(string)
205 ?ssl_cert (byte)(string)
206 ?ssl_cipher (byte)(string)
207 ?ssl_session (byte)(string)
208 ?ssl_key_size (byte)(int) via JkOptions +ForwardKeySize
209 request_terminator (byte)
210 ?body content_length*(var binary)
214 static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
219 apr_uint32_t i, num_headers = 0;
222 const char *session_route, *envvar;
223 const apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
224 const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
226 ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, r, "Into ajp_marshal_into_msgb");
228 if ((method = sc_for_req_method_by_id(r)) == UNKNOWN_METHOD) {
229 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00967)
230 "ajp_marshal_into_msgb - No such method %s",
232 return AJP_EBAD_METHOD;
235 is_ssl = (apr_byte_t) ap_proxy_conn_is_https(r->connection);
237 if (r->headers_in && apr_table_elts(r->headers_in)) {
238 const apr_array_header_t *t = apr_table_elts(r->headers_in);
239 num_headers = t->nelts;
242 remote_host = (char *)ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_HOST, NULL);
246 if (ajp_msg_append_uint8(msg, CMD_AJP13_FORWARD_REQUEST) ||
247 ajp_msg_append_uint8(msg, (apr_byte_t) method) ||
248 ajp_msg_append_string(msg, r->protocol) ||
249 ajp_msg_append_string(msg, uri->path) ||
250 ajp_msg_append_string(msg, r->useragent_ip) ||
251 ajp_msg_append_string(msg, remote_host) ||
252 ajp_msg_append_string(msg, ap_get_server_name(r)) ||
253 ajp_msg_append_uint16(msg, (apr_uint16_t)r->connection->local_addr->port) ||
254 ajp_msg_append_uint8(msg, is_ssl) ||
255 ajp_msg_append_uint16(msg, (apr_uint16_t) num_headers)) {
257 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00968)
258 "ajp_marshal_into_msgb: "
259 "Error appending the message begining");
263 for (i = 0 ; i < num_headers ; i++) {
265 const apr_array_header_t *t = apr_table_elts(r->headers_in);
266 const apr_table_entry_t *elts = (apr_table_entry_t *)t->elts;
268 if ((sc = sc_for_req_header(elts[i].key)) != UNKNOWN_METHOD) {
269 if (ajp_msg_append_uint16(msg, (apr_uint16_t)sc)) {
270 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00969)
271 "ajp_marshal_into_msgb: "
272 "Error appending the header name");
273 return AJP_EOVERFLOW;
277 if (ajp_msg_append_string(msg, elts[i].key)) {
278 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00970)
279 "ajp_marshal_into_msgb: "
280 "Error appending the header name");
281 return AJP_EOVERFLOW;
285 if (ajp_msg_append_string(msg, elts[i].val)) {
286 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00971)
287 "ajp_marshal_into_msgb: "
288 "Error appending the header value");
289 return AJP_EOVERFLOW;
291 ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r,
292 "ajp_marshal_into_msgb: Header[%d] [%s] = [%s]",
293 i, elts[i].key, elts[i].val);
296 /* XXXX need to figure out how to do this
298 if (ajp_msg_append_uint8(msg, SC_A_SECRET) ||
299 ajp_msg_append_string(msg, s->secret)) {
300 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
301 "Error ajp_marshal_into_msgb - "
302 "Error appending secret");
309 if (ajp_msg_append_uint8(msg, SC_A_REMOTE_USER) ||
310 ajp_msg_append_string(msg, r->user)) {
311 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00972)
312 "ajp_marshal_into_msgb: "
313 "Error appending the remote user");
314 return AJP_EOVERFLOW;
317 if (r->ap_auth_type) {
318 if (ajp_msg_append_uint8(msg, SC_A_AUTH_TYPE) ||
319 ajp_msg_append_string(msg, r->ap_auth_type)) {
320 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00973)
321 "ajp_marshal_into_msgb: "
322 "Error appending the auth type");
323 return AJP_EOVERFLOW;
326 /* XXXX ebcdic (args converted?) */
328 if (ajp_msg_append_uint8(msg, SC_A_QUERY_STRING) ||
329 ajp_msg_append_string(msg, uri->query)) {
330 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00974)
331 "ajp_marshal_into_msgb: "
332 "Error appending the query string");
333 return AJP_EOVERFLOW;
336 if ((session_route = apr_table_get(r->notes, "session-route"))) {
337 if (ajp_msg_append_uint8(msg, SC_A_JVM_ROUTE) ||
338 ajp_msg_append_string(msg, session_route)) {
339 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00975)
340 "ajp_marshal_into_msgb: "
341 "Error appending the jvm route");
342 return AJP_EOVERFLOW;
345 /* XXX: Is the subprocess_env a right place?
346 * <Location /examples>
347 * ProxyPass ajp://remote:8009/servlets-examples
348 * SetEnv SSL_SESSION_ID CUSTOM_SSL_SESSION_ID
352 * Only lookup SSL variables if we are currently running HTTPS.
353 * Furthermore ensure that only variables get set in the AJP message
354 * that are not NULL and not empty.
357 if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
358 AJP13_SSL_CLIENT_CERT_INDICATOR))
360 if (ajp_msg_append_uint8(msg, SC_A_SSL_CERT)
361 || ajp_msg_append_string(msg, envvar)) {
362 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00976)
363 "ajp_marshal_into_msgb: "
364 "Error appending the SSL certificates");
365 return AJP_EOVERFLOW;
369 if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
370 AJP13_SSL_CIPHER_INDICATOR))
372 if (ajp_msg_append_uint8(msg, SC_A_SSL_CIPHER)
373 || ajp_msg_append_string(msg, envvar)) {
374 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00977)
375 "ajp_marshal_into_msgb: "
376 "Error appending the SSL ciphers");
377 return AJP_EOVERFLOW;
381 if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
382 AJP13_SSL_SESSION_INDICATOR))
384 if (ajp_msg_append_uint8(msg, SC_A_SSL_SESSION)
385 || ajp_msg_append_string(msg, envvar)) {
386 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00978)
387 "ajp_marshal_into_msgb: "
388 "Error appending the SSL session");
389 return AJP_EOVERFLOW;
393 /* ssl_key_size is required by Servlet 2.3 API */
394 if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
395 AJP13_SSL_KEY_SIZE_INDICATOR))
398 if (ajp_msg_append_uint8(msg, SC_A_SSL_KEY_SIZE)
399 || ajp_msg_append_uint16(msg, (unsigned short) atoi(envvar))) {
400 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00979)
401 "ajp_marshal_into_msgb: "
402 "Error appending the SSL key size");
407 /* Forward the remote port information, which was forgotten
408 * from the builtin data of the AJP 13 protocol.
409 * Since the servlet spec allows to retrieve it via getRemotePort(),
410 * we provide the port to the Tomcat connector as a request
411 * attribute. Modern Tomcat versions know how to retrieve
412 * the remote port from this attribute.
415 const char *key = SC_A_REQ_REMOTE_PORT;
416 char *val = apr_itoa(r->pool, r->useragent_addr->port);
417 if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
418 ajp_msg_append_string(msg, key) ||
419 ajp_msg_append_string(msg, val)) {
420 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00980)
421 "ajp_marshal_into_msgb: "
422 "Error appending attribute %s=%s",
424 return AJP_EOVERFLOW;
427 /* Use the environment vars prefixed with AJP_
428 * and pass it to the header striping that prefix.
430 for (i = 0; i < (apr_uint32_t)arr->nelts; i++) {
431 if (!strncmp(elts[i].key, "AJP_", 4)) {
432 if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
433 ajp_msg_append_string(msg, elts[i].key + 4) ||
434 ajp_msg_append_string(msg, elts[i].val)) {
435 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00981)
436 "ajp_marshal_into_msgb: "
437 "Error appending attribute %s=%s",
438 elts[i].key, elts[i].val);
439 return AJP_EOVERFLOW;
444 if (ajp_msg_append_uint8(msg, SC_A_ARE_DONE)) {
445 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00982)
446 "ajp_marshal_into_msgb: "
447 "Error appending the message end");
448 return AJP_EOVERFLOW;
451 ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, r,
452 "ajp_marshal_into_msgb: Done");
457 AJPV13_RESPONSE/AJPV14_RESPONSE:=
462 num_headers*(res_header_name header_value)
464 terminator boolean <! -- recycle connection or not -->
467 sc_req_header_name | (string)
470 sc_res_header_name | (string)
477 body length*(var binary)
481 static int addit_dammit(void *v, const char *key, const char *val)
483 apr_table_addn(v, key, val);
487 static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
489 proxy_dir_conf *dconf)
494 apr_uint16_t num_headers;
497 rc = ajp_msg_get_uint16(msg, &status);
499 if (rc != APR_SUCCESS) {
500 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00983)
501 "ajp_unmarshal_response: Null status");
506 rc = ajp_msg_get_string(msg, &ptr);
507 if (rc == APR_SUCCESS) {
508 #if APR_CHARSET_EBCDIC /* copy only if we have to */
509 ptr = apr_pstrdup(r->pool, ptr);
510 ap_xlate_proto_from_ascii(ptr, strlen(ptr));
512 r->status_line = apr_psprintf(r->pool, "%d %s", status, ptr);
514 r->status_line = NULL;
517 ap_log_rerror(APLOG_MARK, APLOG_TRACE4, 0, r,
518 "ajp_unmarshal_response: status = %d", status);
520 rc = ajp_msg_get_uint16(msg, &num_headers);
521 if (rc == APR_SUCCESS) {
522 apr_table_t *save_table;
524 /* First, tuck away all already existing cookies */
526 * Could optimize here, but just in case we want to
527 * also save other headers, keep this logic.
529 save_table = apr_table_make(r->pool, num_headers + 2);
530 apr_table_do(addit_dammit, save_table, r->headers_out,
532 r->headers_out = save_table;
534 r->headers_out = NULL;
538 ap_log_rerror(APLOG_MARK, APLOG_TRACE4, 0, r,
539 "ajp_unmarshal_response: Number of headers is = %d",
542 for(i = 0 ; i < (int) num_headers ; i++) {
544 const char *stringname;
546 rc = ajp_msg_peek_uint16(msg, &name);
547 if (rc != APR_SUCCESS) {
551 if ((name & 0XFF00) == 0XA000) {
552 ajp_msg_get_uint16(msg, &name);
553 stringname = long_res_header_for_sc(name);
554 if (stringname == NULL) {
555 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00984)
556 "ajp_unmarshal_response: "
559 return AJP_EBAD_HEADER;
563 rc = ajp_msg_get_string(msg, &stringname);
564 if (rc != APR_SUCCESS) {
565 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00985)
566 "ajp_unmarshal_response: "
570 ap_xlate_proto_from_ascii(stringname, strlen(stringname));
573 rc = ajp_msg_get_string(msg, &value);
574 if (rc != APR_SUCCESS) {
575 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00986)
576 "ajp_unmarshal_response: "
577 "Null header value");
581 /* Set-Cookie need additional processing */
582 if (!strcasecmp(stringname, "Set-Cookie")) {
583 value = ap_proxy_cookie_reverse_map(r, dconf, value);
585 /* Location, Content-Location, URI and Destination need additional
587 else if (!strcasecmp(stringname, "Location")
588 || !strcasecmp(stringname, "Content-Location")
589 || !strcasecmp(stringname, "URI")
590 || !strcasecmp(stringname, "Destination"))
592 value = ap_proxy_location_reverse_map(r, dconf, value);
595 ap_xlate_proto_from_ascii(value, strlen(value));
596 ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r,
597 "ajp_unmarshal_response: Header[%d] [%s] = [%s]",
598 i, stringname, value);
600 apr_table_add(r->headers_out, stringname, value);
602 /* Content-type needs an additional handling */
603 if (strcasecmp(stringname, "Content-Type") == 0) {
604 /* add corresponding filter */
605 ap_set_content_type(r, apr_pstrdup(r->pool, value));
606 ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r,
607 "ajp_unmarshal_response: ap_set_content_type to '%s'", value);
615 * Build the ajp header message and send it
617 apr_status_t ajp_send_header(apr_socket_t *sock,
625 rc = ajp_msg_create(r->pool, buffsize, &msg);
626 if (rc != APR_SUCCESS) {
627 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00987)
628 "ajp_send_header: ajp_msg_create failed");
632 rc = ajp_marshal_into_msgb(msg, r, uri);
633 if (rc != APR_SUCCESS) {
634 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00988)
635 "ajp_send_header: ajp_marshal_into_msgb failed");
639 rc = ajp_ilink_send(sock, msg);
640 ajp_msg_log(r, msg, "ajp_send_header: ajp_ilink_send packet dump");
641 if (rc != APR_SUCCESS) {
642 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00989)
643 "ajp_send_header: ajp_ilink_send failed");
651 * Read the ajp message and return the type of the message.
653 apr_status_t ajp_read_header(apr_socket_t *sock,
662 rc = ajp_msg_reuse(*msg);
663 if (rc != APR_SUCCESS) {
664 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00990)
665 "ajp_read_header: ajp_msg_reuse failed");
670 rc = ajp_msg_create(r->pool, buffsize, msg);
671 if (rc != APR_SUCCESS) {
672 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00991)
673 "ajp_read_header: ajp_msg_create failed");
678 rc = ajp_ilink_receive(sock, *msg);
679 if (rc != APR_SUCCESS) {
680 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00992)
681 "ajp_read_header: ajp_ilink_receive failed");
684 ajp_msg_log(r, *msg, "ajp_read_header: ajp_ilink_receive packet dump");
685 rc = ajp_msg_peek_uint8(*msg, &result);
686 if (rc != APR_SUCCESS) {
687 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00993)
688 "ajp_read_header: ajp_msg_peek_uint8 failed");
691 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
692 "ajp_read_header: ajp_ilink_received %s (0x%02x)",
693 ajp_type_str(result), result);
697 /* parse the msg to read the type */
698 int ajp_parse_type(request_rec *r, ajp_msg_t *msg)
701 ajp_msg_peek_uint8(msg, &result);
702 ap_log_rerror(APLOG_MARK, APLOG_TRACE6, 0, r,
703 "ajp_parse_type: got %s (0x%02x)",
704 ajp_type_str(result), result);
708 /* parse the header */
709 apr_status_t ajp_parse_header(request_rec *r, proxy_dir_conf *conf,
715 rc = ajp_msg_get_uint8(msg, &result);
716 if (rc != APR_SUCCESS) {
717 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00994)
718 "ajp_parse_headers: ajp_msg_get_byte failed");
721 if (result != CMD_AJP13_SEND_HEADERS) {
722 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00995)
723 "ajp_parse_headers: wrong type %s (0x%02x) expecting %s (0x%02x)",
724 ajp_type_str(result), result,
725 ajp_type_str(CMD_AJP13_SEND_HEADERS), CMD_AJP13_SEND_HEADERS);
726 return AJP_EBAD_HEADER;
728 return ajp_unmarshal_response(msg, r, conf);
731 /* parse the body and return data address and length */
732 apr_status_t ajp_parse_data(request_rec *r, ajp_msg_t *msg,
733 apr_uint16_t *len, char **ptr)
737 apr_uint16_t expected_len;
739 rc = ajp_msg_get_uint8(msg, &result);
740 if (rc != APR_SUCCESS) {
741 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00996)
742 "ajp_parse_data: ajp_msg_get_byte failed");
745 if (result != CMD_AJP13_SEND_BODY_CHUNK) {
746 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00997)
747 "ajp_parse_data: wrong type %s (0x%02x) expecting %s (0x%02x)",
748 ajp_type_str(result), result,
749 ajp_type_str(CMD_AJP13_SEND_BODY_CHUNK), CMD_AJP13_SEND_BODY_CHUNK);
750 return AJP_EBAD_HEADER;
752 rc = ajp_msg_get_uint16(msg, len);
753 if (rc != APR_SUCCESS) {
757 * msg->len contains the complete length of the message including all
758 * headers. So the expected length for a CMD_AJP13_SEND_BODY_CHUNK is
759 * msg->len minus the sum of
760 * AJP_HEADER_LEN : The length of the header to every AJP message.
761 * AJP_HEADER_SZ_LEN : The header giving the size of the chunk.
762 * 1 : The CMD_AJP13_SEND_BODY_CHUNK indicator byte (0x03).
763 * 1 : The last byte of this message always seems to be
764 * 0x00 and is not part of the chunk.
766 expected_len = msg->len - (AJP_HEADER_LEN + AJP_HEADER_SZ_LEN + 1 + 1);
767 if (*len != expected_len) {
768 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00998)
769 "ajp_parse_data: Wrong chunk length. Length of chunk is %i,"
770 " expected length is %i.", *len, expected_len);
771 return AJP_EBAD_HEADER;
773 *ptr = (char *)&(msg->buf[msg->pos]);
777 /* Check the reuse flag in CMD_AJP13_END_RESPONSE */
778 apr_status_t ajp_parse_reuse(request_rec *r, ajp_msg_t *msg,
784 rc = ajp_msg_get_uint8(msg, &result);
785 if (rc != APR_SUCCESS) {
786 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00999)
787 "ajp_parse_reuse: ajp_msg_get_byte failed");
790 if (result != CMD_AJP13_END_RESPONSE) {
791 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01000)
792 "ajp_parse_reuse: wrong type %s (0x%02x) expecting %s (0x%02x)",
793 ajp_type_str(result), result,
794 ajp_type_str(CMD_AJP13_END_RESPONSE), CMD_AJP13_END_RESPONSE);
795 return AJP_EBAD_HEADER;
797 return ajp_msg_get_uint8(msg, reuse);
801 * Allocate a msg to send data
803 apr_status_t ajp_alloc_data_msg(apr_pool_t *pool, char **ptr, apr_size_t *len,
808 if ((rc = ajp_msg_create(pool, *len, msg)) != APR_SUCCESS)
811 *ptr = (char *)&((*msg)->buf[6]);
818 * Send the data message
820 apr_status_t ajp_send_data_msg(apr_socket_t *sock,
821 ajp_msg_t *msg, apr_size_t len)
824 msg->buf[4] = (apr_byte_t)((len >> 8) & 0xFF);
825 msg->buf[5] = (apr_byte_t)(len & 0xFF);
827 msg->len += len + 2; /* + 1 XXXX where is '\0' */
829 return ajp_ilink_send(sock, msg);