* process the request and write the response. */
| 1021 | * process the request and write the response. |
| 1022 | */ |
| 1023 | static int fcgi_do_request(apr_pool_t *p, request_rec *r, |
| 1024 | proxy_conn_rec *conn, |
| 1025 | conn_rec *origin, |
| 1026 | proxy_dir_conf *conf, |
| 1027 | apr_uri_t *uri, |
| 1028 | char *url, char *server_portstr, |
| 1029 | apr_bucket_brigade *input_brigade) |
| 1030 | { |
| 1031 | /* Request IDs are arbitrary numbers that we assign to a |
| 1032 | * single request. This would allow multiplex/pipelining of |
| 1033 | * multiple requests to the same FastCGI connection, but |
| 1034 | * we don't support that, and always use a value of '1' to |
| 1035 | * keep things simple. */ |
| 1036 | apr_uint16_t request_id = 1; |
| 1037 | apr_status_t rv; |
| 1038 | apr_pool_t *temp_pool; |
| 1039 | const char *err; |
| 1040 | int bad_request = 0, |
| 1041 | has_responded = 0; |
| 1042 | |
| 1043 | /* Step 1: Send AP_FCGI_BEGIN_REQUEST */ |
| 1044 | rv = send_begin_request(conn, request_id); |
| 1045 | if (rv != APR_SUCCESS) { |
| 1046 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01073) |
| 1047 | "Failed Writing Request to %s:", server_portstr); |
| 1048 | conn->close = 1; |
| 1049 | return HTTP_SERVICE_UNAVAILABLE; |
| 1050 | } |
| 1051 | |
| 1052 | apr_pool_create(&temp_pool, r->pool); |
| 1053 | apr_pool_tag(temp_pool, "proxy_fcgi_do_request"); |
| 1054 | |
| 1055 | /* Step 2: Send Environment via FCGI_PARAMS */ |
| 1056 | rv = send_environment(conn, r, temp_pool, request_id); |
| 1057 | if (rv != APR_SUCCESS) { |
| 1058 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01074) |
| 1059 | "Failed writing Environment to %s:", server_portstr); |
| 1060 | conn->close = 1; |
| 1061 | return HTTP_SERVICE_UNAVAILABLE; |
| 1062 | } |
| 1063 | |
| 1064 | /* Step 3: Read records from the back end server and handle them. */ |
| 1065 | rv = dispatch(conn, conf, r, temp_pool, request_id, |
| 1066 | &err, &bad_request, &has_responded, |
| 1067 | input_brigade); |
| 1068 | if (rv != APR_SUCCESS) { |
| 1069 | /* If the client aborted the connection during retrieval or (partially) |
| 1070 | * sending the response, don't return a HTTP_SERVICE_UNAVAILABLE, since |
| 1071 | * this is not a backend problem. */ |
| 1072 | if (r->connection->aborted) { |
| 1073 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, rv, r, |
| 1074 | "The client aborted the connection."); |
| 1075 | conn->close = 1; |
| 1076 | return OK; |
| 1077 | } |
| 1078 | |
| 1079 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01075) |
| 1080 | "Error dispatching request to %s: %s%s%s", |
no test coverage detected