jfclere 2004/07/29 07:38:18 Modified: ajp/ajplib/test ajp_header.c Log: Add routines to read the response. Revision Changes Path 1.12 +60 -2 jakarta-tomcat-connectors/ajp/ajplib/test/ajp_header.c Index: ajp_header.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/ajp_header.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ajp_header.c 29 Jul 2004 09:58:48 -0000 1.11 +++ ajp_header.c 29 Jul 2004 14:38:18 -0000 1.12 @@ -740,22 +740,80 @@ ajp_msg_t *msg; apr_status_t rc; - ajp_msg_reset(msg); rc = ajp_msg_create(r->pool, &msg); if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "ajp_read_header: ajp_msg_create failed"); return rc; } + ajp_msg_reset(msg); rc = ajp_ilink_receive(sock, msg); if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "ajp_read_header: ajp_ilink_receive failed"); return rc; } - rc = ajp_msg_peek_byte(msg,&result); + rc = ajp_msg_peek_byte(msg, &result); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "ajp_read_header: ajp_ilink_received %02x", result); *data = msg; + return APR_SUCCESS; +} +/* parse the msg to read the type */ +int ajp_parse_type(request_rec *r, void *data) +{ + apr_byte_t result; + ajp_msg_t *msg; + msg = (ajp_msg_t *)data; + ajp_msg_peek_byte(msg, &result); + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, + "ajp_parse_type: got %02x", result); + return (int) result; +} +/* parse the headers */ +apr_status_t ajp_parse_headers(request_rec *r, void *data) +{ + ajp_msg_t *msg; + apr_byte_t result; + apr_status_t rc; + + msg = (ajp_msg_t *)data; + rc = ajp_msg_get_byte(msg, &result); + if (rc != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "ajp_parse_headers: ajp_msg_get_byte failed"); + return rc; + } + if (result != 4) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "ajp_parse_headers: wrong type %02x", result); + return APR_EGENERAL; + } + return ajp_unmarshal_response(msg, r); +} +/* parse the header and return data address and length */ +apr_status_t ajp_parse_data(request_rec *r, void *data, apr_uint16_t *len, char **ptr) +{ + ajp_msg_t *msg; + apr_byte_t result; + apr_status_t rc; + + msg = (ajp_msg_t *)data; + rc = ajp_msg_get_byte(msg, &result); + if (rc != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "ajp_parse_data: ajp_msg_get_byte failed"); + return rc; + } + if (result != 3) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "ajp_parse_data: wrong type %02x", result); + return APR_EGENERAL; + } + rc = ajp_msg_get_uint16(msg, len); + if (rc != APR_SUCCESS) { + return APR_EGENERAL; + } + *ptr = msg->buf[msg->pos]; return APR_SUCCESS; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]