2005-02-20 14:27:00 +00:00
|
|
|
#ifndef _RESPONSE_H_
|
|
|
|
#define _RESPONSE_H_
|
2016-03-19 15:14:35 +00:00
|
|
|
#include "first.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2018-03-25 07:45:05 +00:00
|
|
|
#include "base_decls.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "array.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2009-10-11 14:31:42 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
int http_response_parse(server *srv, connection *con);
|
2005-08-15 09:55:23 +00:00
|
|
|
int http_response_write_header(server *srv, connection *con);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
consistent, shared code to create CGI env
consolidated from CGI, FastCGI, SCGI, SSI
Note: due to prior inconsistencies between the code in mod_cgi,
mod_fastcgi, mod_scgi, and mod_ssi, there are some minor behavior
changes.
CONTENT_LENGTH is now always set, even if 0
(though CONTENT_LENGTH is never set for FASTCGI_AUTHORIZER)
PATH_INFO is created only if present, not if empty.
(mod_fastcgi and mod_ssi previously set PATH_INFO="" (blank value))
PATH_TRANSLATED is now set if PATH_INFO is present
(previously missing from mod_cgi and mod_ssi)
mod_ssi now sets DOCUMENT_ROOT to con->physical.basedir, like others
(previously, mod_ssi set DOCUMENT_ROOT to con->physical.doc_root,
which matched con->physical.basedir unless mod_alias changed basedir)
mod_ssi now sets REQUEST_URI to con->request.orig_uri, like others
(previously, mod_ssi set REQUEST_URI to con->request.uri, which
matched con->request.orig_uri except after redirects, error docs)
2016-10-10 17:37:36 +00:00
|
|
|
typedef struct http_cgi_opts_t {
|
|
|
|
int authorizer;
|
|
|
|
int break_scriptfilename_for_php;
|
|
|
|
buffer *docroot;
|
|
|
|
buffer *strip_request_uri;
|
|
|
|
} http_cgi_opts;
|
|
|
|
|
2017-03-18 04:10:48 +00:00
|
|
|
enum {
|
|
|
|
BACKEND_UNSET = 0,
|
|
|
|
BACKEND_PROXY,
|
|
|
|
BACKEND_CGI,
|
|
|
|
BACKEND_FASTCGI,
|
|
|
|
BACKEND_SCGI
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct http_response_opts_t {
|
2017-03-28 05:57:16 +00:00
|
|
|
int fdfmt;
|
2017-03-18 04:10:48 +00:00
|
|
|
int backend;
|
|
|
|
int authorizer;
|
|
|
|
unsigned short local_redir;
|
|
|
|
unsigned short xsendfile_allow;
|
|
|
|
array *xsendfile_docroot;
|
2017-05-06 03:57:55 +00:00
|
|
|
void *pdata;
|
[core] shared code for socket backends
common codebase for socket backends, based off mod_fastcgi with
some features added for mod_proxy
(mostly intended to reduce code duplication and enhance code isolation)
mod_fastcgi and mod_scgi can now use fastcgi.balance and scgi.balance
for similar behavior as proxy.balance, but the balancing is per-host
and not per-proc. proxy.balance is also per-host and not per-proc.
mod_proxy and mod_scgi can now use proxy.map-extensions and
scgi.map-extensions, similar to fastcgi.map-extensions.
mod_fastcgi behavior change (affects only mod_status):
- statistics tags have been renamed from "fastcgi.*" to "gw.*"
"fastcgi.backend.*" -> "gw.backend.*"
"fastcgi.active-requests" -> "gw.active-requests"
("fastcgi.requests" remains "fastcgi.requests")
("proxy.requests" is new)
("scgi.requests" is new)
mod_scgi behavior change (likely minor):
- removed scgi_proclist_sort_down() and scgi_proclist_sort_up().
procs now chosen based on load as measured by num socket connnections
Note:
modules using gw_backend.[ch] are currently still independent modules.
If it had been written as a single module with fastcgi, scgi, proxy
implementations, then there would have been a chance of breaking some
existing user configurations where module ordering made a difference
for which module handled a given request, though for most people, this
would have made no difference.
Details about mod_fastcgi code transformations:
unsigned int debug -> int debug
fastcgi_env member removed from plugin_config
renamed "fcgi" and "fastcgi" to "gw", and "FCGI" to "GW"
reorganize routines for high-level and lower-level interfaces
some lower-level internal interfaces changed to use host,proc,debug
args rather than knowing about higher-level (app) hctx and plugin_data
tabs->spaces and reformatting
2017-07-14 05:29:18 +00:00
|
|
|
handler_t(*parse)(server *, connection *, struct http_response_opts_t *, buffer *, size_t);
|
|
|
|
handler_t(*headers)(server *, connection *, struct http_response_opts_t *);
|
2017-03-18 04:10:48 +00:00
|
|
|
} http_response_opts;
|
|
|
|
|
consistent, shared code to create CGI env
consolidated from CGI, FastCGI, SCGI, SSI
Note: due to prior inconsistencies between the code in mod_cgi,
mod_fastcgi, mod_scgi, and mod_ssi, there are some minor behavior
changes.
CONTENT_LENGTH is now always set, even if 0
(though CONTENT_LENGTH is never set for FASTCGI_AUTHORIZER)
PATH_INFO is created only if present, not if empty.
(mod_fastcgi and mod_ssi previously set PATH_INFO="" (blank value))
PATH_TRANSLATED is now set if PATH_INFO is present
(previously missing from mod_cgi and mod_ssi)
mod_ssi now sets DOCUMENT_ROOT to con->physical.basedir, like others
(previously, mod_ssi set DOCUMENT_ROOT to con->physical.doc_root,
which matched con->physical.basedir unless mod_alias changed basedir)
mod_ssi now sets REQUEST_URI to con->request.orig_uri, like others
(previously, mod_ssi set REQUEST_URI to con->request.uri, which
matched con->request.orig_uri except after redirects, error docs)
2016-10-10 17:37:36 +00:00
|
|
|
typedef int (*http_cgi_header_append_cb)(void *vdata, const char *k, size_t klen, const char *v, size_t vlen);
|
|
|
|
int http_cgi_headers(server *srv, connection *con, http_cgi_opts *opts, http_cgi_header_append_cb cb, void *vdata);
|
|
|
|
|
2017-03-18 04:10:48 +00:00
|
|
|
handler_t http_response_parse_headers(server *srv, connection *con, http_response_opts *opts, buffer *hdrs);
|
2019-03-01 04:58:49 +00:00
|
|
|
handler_t http_response_read(server *srv, connection *con, http_response_opts *opts, buffer *b, fdnode *fdn);
|
2005-02-20 14:27:00 +00:00
|
|
|
handler_t http_response_prepare(server *srv, connection *con);
|
2018-12-30 19:40:25 +00:00
|
|
|
int http_response_buffer_append_authority(server *srv, connection *con, buffer *b);
|
2019-03-13 06:29:31 +00:00
|
|
|
int http_response_redirect_to_directory(server *srv, connection *con, int status);
|
2019-10-13 17:57:25 +00:00
|
|
|
int http_response_handle_cachable(server *srv, connection *con, const buffer * mtime);
|
2018-09-16 02:48:29 +00:00
|
|
|
void http_response_body_clear(connection *con, int preserve_length);
|
2016-04-21 21:33:16 +00:00
|
|
|
void http_response_send_file (server *srv, connection *con, buffer *path);
|
2016-05-27 04:24:33 +00:00
|
|
|
void http_response_backend_done (server *srv, connection *con);
|
2016-06-19 00:39:00 +00:00
|
|
|
void http_response_backend_error (server *srv, connection *con);
|
2017-05-06 05:23:37 +00:00
|
|
|
void http_response_upgrade_read_body_unknown(server *srv, connection *con);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-10-23 23:44:08 +00:00
|
|
|
const buffer * strftime_cache_get(server *srv, time_t last_mod);
|
2005-02-20 14:27:00 +00:00
|
|
|
#endif
|