| 318 | } proxy_http_req_t; |
| 319 | |
| 320 | static int stream_reqbody(proxy_http_req_t *req) |
| 321 | { |
| 322 | request_rec *r = req->r; |
| 323 | int seen_eos = 0, rv = OK; |
| 324 | apr_size_t hdr_len; |
| 325 | char chunk_hdr[20]; /* must be here due to transient bucket. */ |
| 326 | conn_rec *origin = req->origin; |
| 327 | proxy_conn_rec *p_conn = req->backend; |
| 328 | apr_bucket_alloc_t *bucket_alloc = req->bucket_alloc; |
| 329 | apr_bucket_brigade *header_brigade = req->header_brigade; |
| 330 | apr_bucket_brigade *input_brigade = req->input_brigade; |
| 331 | rb_methods rb_method = req->rb_method; |
| 332 | apr_off_t bytes, bytes_streamed = 0; |
| 333 | apr_bucket *e; |
| 334 | |
| 335 | do { |
| 336 | if (APR_BRIGADE_EMPTY(input_brigade) |
| 337 | && APR_BRIGADE_EMPTY(header_brigade)) { |
| 338 | rv = ap_proxy_read_input(r, p_conn, input_brigade, |
| 339 | HUGE_STRING_LEN); |
| 340 | if (rv != OK) { |
| 341 | return rv; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | if (!APR_BRIGADE_EMPTY(input_brigade)) { |
| 346 | /* If this brigade contains EOS, remove it and be done. */ |
| 347 | if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(input_brigade))) { |
| 348 | seen_eos = 1; |
| 349 | |
| 350 | /* We can't pass this EOS to the output_filters. */ |
| 351 | e = APR_BRIGADE_LAST(input_brigade); |
| 352 | apr_bucket_delete(e); |
| 353 | } |
| 354 | |
| 355 | apr_brigade_length(input_brigade, 1, &bytes); |
| 356 | bytes_streamed += bytes; |
| 357 | |
| 358 | if (rb_method == RB_STREAM_CHUNKED) { |
| 359 | if (bytes) { |
| 360 | /* |
| 361 | * Prepend the size of the chunk |
| 362 | */ |
| 363 | hdr_len = apr_snprintf(chunk_hdr, sizeof(chunk_hdr), |
| 364 | "%" APR_UINT64_T_HEX_FMT CRLF, |
| 365 | (apr_uint64_t)bytes); |
| 366 | ap_xlate_proto_to_ascii(chunk_hdr, hdr_len); |
| 367 | e = apr_bucket_transient_create(chunk_hdr, hdr_len, |
| 368 | bucket_alloc); |
| 369 | APR_BRIGADE_INSERT_HEAD(input_brigade, e); |
| 370 | |
| 371 | /* |
| 372 | * Append the end-of-chunk CRLF |
| 373 | */ |
| 374 | e = apr_bucket_immortal_create(CRLF_ASCII, 2, bucket_alloc); |
| 375 | APR_BRIGADE_INSERT_TAIL(input_brigade, e); |
| 376 | } |
| 377 | if (seen_eos) { |
no test coverage detected