#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H
#include <cx/string.h>
#include "sessionhandler.h"
#include "../public/nsapi.h"
#include "../util/pool.h"
#include "session.h"
#include "request.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _http_request HTTPRequest;
typedef struct _header Header;
typedef struct _header_array HeaderArray;
struct _http_request {
Connection *connection;
cxmutstr request_line;
cxmutstr method;
cxmutstr uri;
cxmutstr httpv;
HeaderArray *headers;
netbuf *netbuf;
time_t req_start;
};
struct _header {
cxmutstr name;
cxmutstr value;
};
struct _header_array {
HeaderArray *next;
Header *headers;
int len;
int alloc;
};
void http_request_init(HTTPRequest *req);
void http_request_cleanup(HTTPRequest *req);
cxmutstr http_request_get_abspath(HTTPRequest *req);
NSAPISession* nsapisession_create(
pool_handle_t *pool);
int nsapisession_setconnection(NSAPISession *sn, Connection *conn, netbuf *inbuf, IOStream **io);
int handle_request(HTTPRequest *request,
threadpool_t *thrpool, EventHandler *ev);
int nsapi_start_request(
HTTPRequest *request,
threadpool_t *thrpool,
EventHandler *ev,
pool_handle_t *pool);
void header_add(HeaderArray *hd, cxmutstr name, cxmutstr value);
void header_array_free(HeaderArray *hd);
int nsapi_handle_request(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq);
void nsapi_saf_return(Session *sn, Request *rq,
int ret);;
void request_free_resources(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_authtrans(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_nametrans(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_pathcheck(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_service(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_error(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_addlog(NSAPISession *sn, NSAPIRequest *rq);
int nsapi_exec(directive *d, NSAPISession *sn, NSAPIRequest *rq);
int nsapi_exec_tp(
directive *d,
NSAPISession *sn,
NSAPIRequest *rq,
threadpool_t *pool);
void nsapi_change_threadpool(
NSAPISession *sn,
NSAPIRequest *rq,
threadpool_t *thrpool);
void* thrpool_exec(
void *d);
void* thrpool_change(
void *data);
int add_objects(
HTTPObjectConfig *objs,
httpd_objset *os,
NSAPISession *sn,
NSAPIRequest *rq,
char *name,
char *path);
int method_match(
char *cmp,
char *method);
int contenttype_match(cxstring cmp, cxstring ctype);
int request_initialize(
pool_handle_t *pool,
HTTPRequest *hrq,
NSAPIRequest *nrq);
#ifdef __cplusplus
}
#endif
#endif