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>
|
|
|
|
|
2020-01-13 02:51:12 +00:00
|
|
|
int http_response_parse(server *srv, request_st *r);
|
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;
|
2020-01-13 02:51:12 +00:00
|
|
|
handler_t(*parse)(request_st *, struct http_response_opts_t *, buffer *, size_t);
|
|
|
|
handler_t(*headers)(request_st *, 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);
|
2020-01-13 02:51:12 +00:00
|
|
|
int http_cgi_headers(request_st *r, http_cgi_opts *opts, http_cgi_header_append_cb cb, void *vdata);
|
|
|
|
|
2020-09-17 23:29:59 +00:00
|
|
|
typedef int (*http_response_send_1xx_cb)(request_st *r, connection *con);
|
|
|
|
__attribute_cold__
|
|
|
|
void http_response_send_1xx_cb_set (http_response_send_1xx_cb fn, int vers);
|
|
|
|
int http_response_send_1xx (request_st *r);
|
|
|
|
|
2020-01-13 02:51:12 +00:00
|
|
|
handler_t http_response_parse_headers(request_st *r, http_response_opts *opts, buffer *hdrs);
|
|
|
|
handler_t http_response_read(request_st *r, http_response_opts *opts, buffer *b, fdnode *fdn);
|
2020-01-21 02:05:56 +00:00
|
|
|
|
2020-08-11 05:10:57 +00:00
|
|
|
__attribute_cold__
|
|
|
|
handler_t http_response_reqbody_read_error(request_st *r, int http_status);
|
|
|
|
|
2020-11-10 11:10:27 +00:00
|
|
|
int http_response_buffer_append_authority(request_st *r, buffer *o);
|
2020-01-13 02:51:12 +00:00
|
|
|
int http_response_redirect_to_directory(request_st *r, int status);
|
2020-11-22 07:41:11 +00:00
|
|
|
const buffer * http_response_set_last_modified(request_st *r, time_t lmtime);
|
|
|
|
int http_response_handle_cachable(request_st *r, const buffer *lmod, time_t lmtime);
|
2020-01-13 02:51:12 +00:00
|
|
|
void http_response_body_clear(request_st *r, int preserve_length);
|
2020-08-11 05:10:57 +00:00
|
|
|
void http_response_reset(request_st *r);
|
2020-01-13 02:51:12 +00:00
|
|
|
void http_response_send_file (request_st *r, buffer *path);
|
|
|
|
void http_response_backend_done (request_st *r);
|
|
|
|
void http_response_backend_error (request_st *r);
|
|
|
|
void http_response_upgrade_read_body_unknown(request_st *r);
|
2020-08-25 10:34:47 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
|
|
|
int http_response_omit_header(request_st *r, const data_string *ds);
|
|
|
|
|
2020-08-13 02:38:59 +00:00
|
|
|
void http_response_write_header(request_st *r);
|
|
|
|
handler_t http_response_handler(request_st *r);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2019-12-10 04:57:53 +00:00
|
|
|
__attribute_cold__
|
|
|
|
void strftime_cache_reset(void);
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
#endif
|