1 Description: Patch to set CONTENT_LENGTH FCGI params based on actual request body
3 Bug: https://issues.apache.org/bugzilla/show_bug.cgi?id=53332
5 diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' libapache2-mod-fcgid-2.3.6~/modules/fcgid/fcgid_spawn_ctl.c libapache2-mod-fcgid-2.3.6/modules/fcgid/fcgid_spawn_ctl.c
6 --- mod_fcgid-2.3.6.orig/modules/fcgid/fcgid_bridge.c 2012-05-30 09:53:20.928783540 +0100
7 +++ mod_fcgid-2.3.6/modules/fcgid/fcgid_bridge.c 2012-05-30 18:04:01.648850877 +0100
8 @@ -662,6 +662,11 @@ static int add_request_body(request_rec
9 apr_brigade_destroy(input_brigade);
10 apr_brigade_destroy(tmp_brigade);
13 + apr_snprintf(sizestr, sizeof sizestr, "%" APR_OFF_T_FMT, request_size);
14 + apr_table_set(r->subprocess_env, "CONTENT_LENGTH", sizestr);
15 + apr_table_unset(r->subprocess_env, "HTTP_TRANSFER_ENCODING");
17 /* Append an empty body stdin header */
18 stdin_request_header = apr_bucket_alloc(sizeof(FCGI_Header),
19 r->connection->bucket_alloc);
20 @@ -682,31 +687,37 @@ static int add_request_body(request_rec
21 int bridge_request(request_rec * r, int role, fcgid_cmd_conf *cmd_conf)
23 apr_bucket_brigade *output_brigade;
24 + apr_bucket_brigade *header_brigade;
25 apr_bucket *bucket_eos;
26 - char **envp = ap_create_environment(r->pool,
30 /* Create brigade for the request to fastcgi server */
32 apr_brigade_create(r->pool, r->connection->bucket_alloc);
34 + apr_brigade_create(r->pool, r->connection->bucket_alloc);
36 + if (role == FCGI_RESPONDER) {
37 + rc = add_request_body(r, r->pool, output_brigade);
43 + char **envp = ap_create_environment(r->pool,
46 /* Build the begin request and environ request, append them to output_brigade */
47 if (!build_begin_block
48 - (role, r, r->connection->bucket_alloc, output_brigade)
49 + (role, r, r->connection->bucket_alloc, header_brigade)
50 || !build_env_block(r, envp, r->connection->bucket_alloc,
53 ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
54 "mod_fcgid: can't build begin or env request");
55 return HTTP_INTERNAL_SERVER_ERROR;
58 - if (role == FCGI_RESPONDER) {
59 - rc = add_request_body(r, r->pool, output_brigade);
64 + APR_BRIGADE_PREPEND(output_brigade,header_brigade);
66 /* The eos bucket now */
67 bucket_eos = apr_bucket_eos_create(r->connection->bucket_alloc);