static ngx_int_t ngx_http_ajp_create_request(ngx_http_request_t *r) { ajp_msg_t *msg; ngx_chain_t *cl; ngx_http_ajp_ctx_t *a; ngx_http_ajp_loc_conf_t *alcf; a = ngx_http_get_module_ctx(r, ngx_http_ajp_module); alcf = ngx_http_get_module_loc_conf(r, ngx_http_ajp_module); if (a == NULL || alcf == NULL) { return NGX_ERROR; } msg = ajp_msg_reuse(&a->msg); if (NGX_OK != ajp_msg_create_buffer(r->pool, alcf->ajp_header_packet_buffer_size_conf, msg)) { return NGX_ERROR; } if (NGX_OK != ajp_marshal_into_msgb(msg, r, alcf)) { return NGX_ERROR; } ajp_msg_end(msg); cl = ngx_alloc_chain_link(r->pool); if (cl == NULL) { return NGX_ERROR; } cl->buf = msg->buf; cl->buf->flush = 1; a->state = ngx_http_ajp_st_forward_request_sent; if (alcf->upstream.pass_request_body) { a->body = r->upstream->request_bufs; r->upstream->request_bufs = cl; cl->next = ajp_data_msg_send_body(r, alcf->max_ajp_data_packet_size_conf, &a->body); if (a->body) { a->state = ngx_http_ajp_st_request_body_data_sending; } else { a->state = ngx_http_ajp_st_request_send_all_done; } } else { a->state = ngx_http_ajp_st_request_send_all_done; r->upstream->request_bufs = cl; cl->next = NULL; } return NGX_OK; }
/* * Build the ajp header message and send it */ apr_status_t ajp_send_header(apr_socket_t *sock, request_rec *r, apr_size_t buffsize, apr_uri_t *uri) { ajp_msg_t *msg; apr_status_t rc; rc = ajp_msg_create(r->pool, buffsize, &msg); if (rc != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00987) "ajp_send_header: ajp_msg_create failed"); return rc; } rc = ajp_marshal_into_msgb(msg, r, uri); if (rc != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00988) "ajp_send_header: ajp_marshal_into_msgb failed"); return rc; } rc = ajp_ilink_send(sock, msg); ajp_msg_log(r, msg, "ajp_send_header: ajp_ilink_send packet dump"); if (rc != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00989) "ajp_send_header: ajp_ilink_send failed"); return rc; } return APR_SUCCESS; }