1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

* modules/generators/mod_cgi.c (cgi_handler): Combine common code

between nph and non-nph handling; use a CGI bucket for both cases if
APR_FILES_AS_SOCKETS.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103621 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joe Orton
2004-05-05 14:52:44 +00:00
parent 47e4bf38fc
commit 46fb957d01

View File

@@ -726,6 +726,7 @@ static int cgi_handler(request_rec *r)
cgi_server_conf *conf;
apr_status_t rv;
cgi_exec_info_t e_info;
conn_rec *c = r->connection;
if(strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script"))
return DECLINED;
@@ -807,7 +808,7 @@ static int cgi_handler(request_rec *r)
/* Transfer any put/post args, CERN style...
* Note that we already ignore SIGPIPE in the core server.
*/
bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
bb = apr_brigade_create(r->pool, c->bucket_alloc);
seen_eos = 0;
child_stopped_reading = 0;
if (conf->logname) {
@@ -883,25 +884,28 @@ static int cgi_handler(request_rec *r)
apr_file_flush(script_out);
apr_file_close(script_out);
AP_DEBUG_ASSERT(script_in != NULL);
apr_brigade_cleanup(bb);
#if APR_FILES_AS_SOCKETS
apr_file_pipe_timeout_set(script_in, 0);
apr_file_pipe_timeout_set(script_err, 0);
b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc);
#else
b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
#endif
APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
/* Handle script return... */
if (script_in && !nph) {
conn_rec *c = r->connection;
if (!nph) {
const char *location;
char sbuf[MAX_STRING_LEN];
int ret;
#if APR_FILES_AS_SOCKETS
apr_file_pipe_timeout_set(script_in, 0);
apr_file_pipe_timeout_set(script_err, 0);
b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc);
#else
b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
#endif
APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) {
return log_script(r, conf, ret, dbuf, sbuf, bb, script_err);
}
@@ -952,9 +956,7 @@ static int cgi_handler(request_rec *r)
apr_file_close(script_err);
}
if (script_in && nph) {
conn_rec *c = r->connection;
else /* nph */ {
struct ap_filter_t *cur;
/* get rid of all filters up through protocol... since we
@@ -968,11 +970,6 @@ static int cgi_handler(request_rec *r)
}
r->output_filters = r->proto_output_filters = cur;
bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb);
}