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);
|
2019-11-25 06:54:08 +00:00
|
|
|
int http_response_write_header(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;
|
2019-11-19 01:15:26 +00:00
|
|
|
const buffer *docroot;
|
|
|
|
const buffer *strip_request_uri;
|
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
|
|
|
} 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;
|
2019-11-07 05:15:17 +00:00
|
|
|
const array *xsendfile_docroot;
|
2017-05-06 03:57:55 +00:00
|
|
|
void *pdata;
|
2019-11-25 06:54:08 +00:00
|
|
|
handler_t(*parse)(connection *, struct http_response_opts_t *, buffer *, size_t);
|
|
|
|
handler_t(*headers)(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);
|
2019-11-25 06:54:08 +00:00
|
|
|
int http_cgi_headers(connection *con, http_cgi_opts *opts, http_cgi_header_append_cb cb, void *vdata);
|
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
|
|
|
|
2019-11-25 06:54:08 +00:00
|
|
|
handler_t http_response_parse_headers(connection *con, http_response_opts *opts, buffer *hdrs);
|
|
|
|
handler_t http_response_read(connection *con, http_response_opts *opts, buffer *b, fdnode *fdn);
|
2019-11-26 07:13:05 +00:00
|
|
|
handler_t http_response_prepare(connection *con);
|
2019-11-25 06:54:08 +00:00
|
|
|
int http_response_redirect_to_directory(connection *con, int status);
|
|
|
|
int http_response_handle_cachable(connection *con, const buffer * mtime);
|
2018-09-16 02:48:29 +00:00
|
|
|
void http_response_body_clear(connection *con, int preserve_length);
|
2019-11-25 06:54:08 +00:00
|
|
|
void http_response_send_file (connection *con, buffer *path);
|
|
|
|
void http_response_backend_done (connection *con);
|
|
|
|
void http_response_backend_error (connection *con);
|
|
|
|
void http_response_upgrade_read_body_unknown(connection *con);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-12-10 04:57:53 +00:00
|
|
|
__attribute_cold__
|
|
|
|
void strftime_cache_reset(void);
|
|
|
|
|
|
|
|
const buffer * strftime_cache_get(time_t last_mod);
|
2005-02-20 14:27:00 +00:00
|
|
|
#endif
|