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

13 Commits

Author SHA1 Message Date
Joe Orton
e03580554f Explicitly reject CGI output which includes a Transfer-Encoding
header, rather than drop it and send what's likely to be an unexpected
or corrupted response.

* modules/generators/cgi_common.h (cgi_handle_response): Send a 502
  error if Transfer-Encoding is present in the response headers.

PR: 68970
Github: closes #444


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1917835 13f79535-47bb-0310-9956-ffa450edef68
2024-05-20 09:18:10 +00:00
Eric Covener
61645eaac8 let httpd handle CL/TE for non-http handlers
Submitted By: ylavic, covener



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1916769 13f79535-47bb-0310-9956-ffa450edef68
2024-04-03 11:49:53 +00:00
Yann Ylavic
b36b129f34 mod_cgi[d]: Close the connection after handling nph- scripts.
The HTTP output filters chain is bypassed for nph- scripts (whatever this
means), so there is no way to know whether the connection is reusable after
sending the cgi response (opaque header + body).

Set r->connection->keepalive = AP_CONN_CLOSE unconditionally.

For instance test frameork's "nph-foldhdr.pl" script responds with HTTP/1.0
and no Content-Length so closing the connection is the only way to detect the
end of response for the peer.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897563 13f79535-47bb-0310-9956-ffa450edef68
2022-01-28 12:32:25 +00:00
Joe Orton
eabfcda175 Further re-unification of code duplicated across mod_cgi/mod_cgid into
cgi_common.h.  Functional changes:

- brings the PR 61980 fix to mod_cgid as well, and 
- some mod_cgid-specific APLOGNOs are dropped in favour of the
  code used in the equivalent error path in mod_cgi

... otherwise no user-visible changes (intended).

* modules/generators/cgi_common.h (log_scripterror, log_script_err): Move
  here from mod_cgi.
  (cgi_handle_exec): Move here, renamed from mod_cgi's handle_exec.
  (cgi_optfns_retrieve): New function, split out from mod_cgi's cgi_post_config.
  
* modules/generators/mod_cgid.c: Adjust accordingly, update to pass
  logno separately.
  (register_hooks): Register cgi_optfns_retrieve.

* modules/generators/mod_cgi.c: Adjust accordingly.
  (register_hooks): Register cgi_optfns_retrieve.

Github: closes #141


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1881559 13f79535-47bb-0310-9956-ffa450edef68
2020-09-08 14:08:22 +00:00
Joe Orton
066f641991 * modules/generators/cgi_common.h (cgi_handle_response): Avoid trying
to read the output brigade twice in the case of a timeout.
  
PR: 64709


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1881459 13f79535-47bb-0310-9956-ffa450edef68
2020-09-04 13:56:25 +00:00
Joe Orton
2f76ae80c0 * modules/generators/cgi_common.h (cgi_handle_request): Catch
(unlikely) apr_bucket_read() failure when reading request.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874511 13f79535-47bb-0310-9956-ffa450edef68
2020-02-25 16:34:47 +00:00
Joe Orton
82b87850ee * modules/generators/cgi_common.h (cgi_handle_request): Factor out
near-identical common code from mod_cgid, mod_cgi.

* modules/generators/mod_cgid.c (cgid_handler),
  modules/generators/mod_cgi.c (cgi_handler):
  Adjust to use cgi_handle_request.

Github: closes #97


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874491 13f79535-47bb-0310-9956-ffa450edef68
2020-02-25 12:34:00 +00:00
Joe Orton
c5fcb84758 Add comment, no functional change.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1869421 13f79535-47bb-0310-9956-ffa450edef68
2019-11-05 16:44:22 +00:00
Joe Orton
f0abf76803 Fix build broken w/o --enable-cgid-fdpassing by r1867968:
* modules/generators/cgi_common.h: Only define CGI bucket type
  if WANT_CGI_BUCKET is defined.

* modules/generators/mod_cgi.c: Always include cgi_common.h, defining
  WANT_CGI_BUCKET iff APR_FILES_AS_SOCKETS is defined

* modules/generators/mod_cgid.c: Always include cgi_common.h, defining
  WANT_CGI_BUCKET iff HAVE_CGID_FDPASSING (--enable-cgid-fdpassing).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867971 13f79535-47bb-0310-9956-ffa450edef68
2019-10-04 09:56:42 +00:00
Joe Orton
4a835a7745 * modules/generators/cgi_common.h (discard_script_output): Simplify
slightly and ensure constant rather than unlimited memory
  consumption when discarding CGI script output (for e.g. a redirect
  response).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867970 13f79535-47bb-0310-9956-ffa450edef68
2019-10-04 09:24:07 +00:00
Joe Orton
54c71d419a Move common (and near-identical) code for CGI response output handling
to cgi_common.h; the diff between the modules for this code was as
follows:

https://people.apache.org/~jorton/mod_cgi-to-cgid-handler.diff

Change from previous: mod_cgi will now explicitly discard output when
returning HTTP_MOVED_TEMPORARILY for relative redirects (should not be
functionally different), TRACE1 logging of ap_pass_brigade failures
for mod_cgid is dropped.

* modules/generators/cgi_common.h (cgi_handle_response): New function,
  factored out from mod_cgid.
  (discard_script_output): Copied function from mod_cgi/d unchanged.

* modules/generator/mod_cgid.c (cgid_handler),
  modules/generator/mod_cgi.c (cgi_handler): Use cgi_handle_response.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867968 13f79535-47bb-0310-9956-ffa450edef68
2019-10-04 09:20:33 +00:00
Joe Orton
58b69a442e * modules/generators/cgi_common.h (cgi_bucket_create):
Disable APR timeout handling here for all callers.

* modules/generators/mod_cgi.c (cgi_handler): ... drop it here.

PR: 63797


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867882 13f79535-47bb-0310-9956-ffa450edef68
2019-10-02 10:41:22 +00:00
Joe Orton
eda8ddfc71 mod_cgid: Continuation of r1862968, experimental fd passing support.
Split out CGI bucket implementation from mod_cgi and use in both
mod_cgi and mod_cgid, bringing stderr handling in mod_cgid up to par
with mod_cgi.  (There is a lot of code which has been copied between
mod_cgi{,d} so there's scope for further reduction of source
duplication between the modules using this header)

* modules/generators/cgi_common.h: Copied from mod_cgi.c, removed
  everything but the CGI bucket implementation with only one change:
  (struct cgi_bucket_data, cgi_bucket_create, cgi_bucket_read): Take a
  timeout on bucket creation, store and use on reads.

* modules/generators/mod_cgi.c [APR_FILES_AS_SOCKETS]: Include
  cgi_common.h.
  (cgi_handler): Pass configured timeout to CGI bucket.

* modules/generators/mod_cgid.c: Include cgi_common.h.
  (log_script_err): Copy from mod_cgi.c.
  (log_script): Use log_script_err.
  (send_req): Take fd for stderr.
  (cgid_child_errfn): Handle fd-passing case by writing error
  to stderr for client to pass through ap_log_rerror.
  (cgid_handler): Create pipe for stderr, pass write-end to
  server via send_req, use read-end to create CGI bucket.  Handle
  stderr output in failure paths.

PR: 54221


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1863191 13f79535-47bb-0310-9956-ffa450edef68
2019-07-17 07:51:53 +00:00