| 2314 | #endif |
| 2315 | |
| 2316 | AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers) |
| 2317 | { |
| 2318 | hdr_ptr x; |
| 2319 | char *response_line = NULL; |
| 2320 | const char *status_line; |
| 2321 | request_rec *rr; |
| 2322 | |
| 2323 | if (r->proto_num < HTTP_VERSION(1,1)) { |
| 2324 | /* don't send interim response to HTTP/1.0 Client */ |
| 2325 | return; |
| 2326 | } |
| 2327 | if (!ap_is_HTTP_INFO(r->status)) { |
| 2328 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00575) |
| 2329 | "Status is %d - not sending interim response", r->status); |
| 2330 | return; |
| 2331 | } |
| 2332 | if (r->status == HTTP_CONTINUE) { |
| 2333 | if (!r->expecting_100) { |
| 2334 | /* |
| 2335 | * Don't send 100-Continue when there was no Expect: 100-continue |
| 2336 | * in the request headers. For origin servers this is a SHOULD NOT |
| 2337 | * for proxies it is a MUST NOT according to RFC 2616 8.2.3 |
| 2338 | */ |
| 2339 | return; |
| 2340 | } |
| 2341 | |
| 2342 | /* if we send an interim response, we're no longer in a state of |
| 2343 | * expecting one. Also, this could feasibly be in a subrequest, |
| 2344 | * so we need to propagate the fact that we responded. |
| 2345 | */ |
| 2346 | for (rr = r; rr != NULL; rr = rr->main) { |
| 2347 | rr->expecting_100 = 0; |
| 2348 | } |
| 2349 | } |
| 2350 | |
| 2351 | status_line = r->status_line; |
| 2352 | if (status_line == NULL) { |
| 2353 | status_line = ap_get_status_line_ex(r->pool, r->status); |
| 2354 | } |
| 2355 | response_line = apr_pstrcat(r->pool, |
| 2356 | AP_SERVER_PROTOCOL " ", status_line, CRLF, |
| 2357 | NULL); |
| 2358 | ap_xlate_proto_to_ascii(response_line, strlen(response_line)); |
| 2359 | |
| 2360 | x.f = r->connection->output_filters; |
| 2361 | x.bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); |
| 2362 | |
| 2363 | ap_fputs(x.f, x.bb, response_line); |
| 2364 | if (send_headers) { |
| 2365 | apr_table_do(send_header, &x, r->headers_out, NULL); |
| 2366 | apr_table_clear(r->headers_out); |
| 2367 | } |
| 2368 | ap_fputs(x.f, x.bb, CRLF_ASCII); |
| 2369 | ap_fflush(x.f, x.bb); |
| 2370 | apr_brigade_destroy(x.bb); |
| 2371 | } |
| 2372 | |
| 2373 | /* |
no test coverage detected