1 #ifndef _RESPONSE_H_ 2 #define _RESPONSE_H_ 3 #include "first.h" 4 5 #include "sys-time.h" 6 7 #include "base_decls.h" 8 #include "buffer.h" 9 #include "array.h" 10 11 struct stat_cache_entry;/* declaration */ 12 struct chunkqueue; /* declaration */ 13 14 int http_response_parse(server *srv, request_st *r); 15 16 enum { 17 BACKEND_PROXY = 0 18 ,BACKEND_CGI 19 ,BACKEND_FASTCGI 20 ,BACKEND_SCGI 21 ,BACKEND_AJP13 22 }; 23 24 typedef struct http_response_opts_t { 25 uint32_t max_per_read; 26 int fdfmt; 27 int backend; 28 int authorizer; /* bool *//*(maybe overloaded w/ response streaming flags)*/ 29 uint8_t simple_accum; /* bool */ 30 uint8_t local_redir; /* 0,1,2 */ 31 uint8_t xsendfile_allow; /* bool */ 32 const array *xsendfile_docroot; 33 void *pdata; 34 handler_t(*parse)(request_st *, struct http_response_opts_t *, buffer *, size_t); 35 handler_t(*headers)(request_st *, struct http_response_opts_t *); 36 } http_response_opts; 37 38 typedef int (*http_response_send_1xx_cb)(request_st *r, connection *con); 39 __attribute_cold__ 40 void http_response_send_1xx_cb_set (http_response_send_1xx_cb fn, int vers); 41 int http_response_send_1xx (request_st *r); 42 43 handler_t http_response_parse_headers(request_st *r, http_response_opts *opts, buffer *hdrs); 44 handler_t http_response_read(request_st *r, http_response_opts *opts, buffer *b, fdnode *fdn); 45 46 __attribute_cold__ 47 handler_t http_response_reqbody_read_error(request_st *r, int http_status); 48 49 int http_response_buffer_append_authority(request_st *r, buffer *o); 50 int http_response_redirect_to_directory(request_st *r, int status); 51 const buffer * http_response_set_last_modified(request_st *r, unix_time64_t lmtime); 52 int http_response_handle_cachable(request_st *r, const buffer *lmod, unix_time64_t lmtime); 53 void http_response_body_clear(request_st *r, int preserve_length); 54 void http_response_reset(request_st *r); 55 void http_response_send_file (request_st *r, buffer *path, struct stat_cache_entry *sce); 56 void http_response_backend_done (request_st *r); 57 void http_response_backend_error (request_st *r); 58 void http_response_upgrade_read_body_unknown(request_st *r); 59 int http_response_transfer_cqlen(request_st *r, struct chunkqueue *cq, size_t len); 60 61 __attribute_cold__ 62 int http_response_omit_header(request_st *r, const data_string *ds); 63 64 void http_response_write_header(request_st *r); 65 handler_t http_response_handler(request_st *r); 66 67 __attribute_cold__ 68 void strftime_cache_reset(void); 69 70 #endif 71