You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.7 KiB

  1. From 51ff7ac504f7001dc54807f9b2a72de891ab9ee5 Mon Sep 17 00:00:00 2001
  2. From: Glenn Strauss <gstrauss@gluelogic.com>
  3. Date: Wed, 22 Feb 2017 11:58:21 -0500
  4. Subject: [PATCH] [mod_cgi] status 200 OK if no hdrs (deprecated) (#2786)
  5. set status 200 OK if CGI does not return CGI headers
  6. Note:
  7. This mode in lighttpd is deprecated and may be removed in the next major
  8. release of lighttpd. CGI scripts should return a proper CGI header in
  9. the response, even if that header is empty and followed by a blank line,
  10. before return response body.
  11. Without a proper CGI response header, the first line(s) of the response
  12. might be incorrectly construed as being CGI response headers, especially
  13. if they contain ':', and response may be corrupted. That is why this
  14. mode is deprecated (and not supported in numerous other web servers).
  15. The minimal valid CGI response header is "\n", which lighttpd will treat
  16. as equivalent to "Status: 200\n\n"
  17. x-ref:
  18. "error 500 (mod_cgi.c.601) cgi died"
  19. https://redmine.lighttpd.net/issues/2786
  20. ---
  21. src/mod_cgi.c | 2 ++
  22. 1 file changed, 2 insertions(+)
  23. --- a/src/mod_cgi.c
  24. +++ b/src/mod_cgi.c
  25. @@ -502,6 +502,7 @@ static int cgi_demux_response(server *sr
  26. if (0 != http_chunk_append_buffer(srv, con, hctx->response_header)) {
  27. return FDEVENT_HANDLED_ERROR;
  28. }
  29. + if (0 == con->http_status) con->http_status = 200; /* OK */
  30. } else {
  31. const char *bstart;
  32. size_t blen;
  33. @@ -846,6 +847,7 @@ static handler_t cgi_handle_fdevent(serv
  34. cgi_connection_close(srv, hctx);
  35. return HANDLER_ERROR;
  36. }
  37. + if (0 == con->http_status) con->http_status = 200; /* OK */
  38. } else {
  39. # if 0
  40. log_error_write(srv, __FILE__, __LINE__, "sddd", "got HUP from cgi", con->fd, hctx->fd, revents);