#ifndef __HTTP_REQUEST_H__
#define __HTTP_REQUEST_H__

#include "message.h"
#include "processor.h"

/* from continuity.h */
#ifndef STATUS_OK

#define STATUS_OK 1
#define STATUS_ERROR 2
#define STATUS_PROCEED 3
#define STATUS_EXIT 4
#define STATUS_RESTART 5

#endif

typedef struct s_HttpRequest HttpRequest;

HttpRequest * http_request_new (Message *requestMessage, Processor *processor);
void http_request_destroy (void *ptr);

const char * http_request_getToken (const HttpRequest *request);
const char * http_request_getUri (const HttpRequest *request);
const char * http_request_getQuery (const HttpRequest *request);
const char * http_request_getMethod (const HttpRequest *request);
const char * http_request_getDocRoot (const HttpRequest *request);
const char * http_request_getRemoteIP (const HttpRequest *request);

const dynTstring * http_request_getVariableString (const HttpRequest *request, const char *variable);
const char * http_request_getVariable (const HttpRequest *request, const char *variable);

const char * http_request_getRequestHeader (const HttpRequest *request, const char *key);
const dynTstring * http_request_getRequestHeaderString (const HttpRequest *request, const char *key);

bool http_request_writeData (HttpRequest *request, const char *data, int dataLen);
bool http_request_writeString (HttpRequest *request, const char *data);

bool http_request_finish (const HttpRequest *request);

int http_request_getEntity (HttpRequest *request, char *outBuf, int bufLen);
bool http_request_isEntireEntityLoaded (const HttpRequest *request);

const dynTstring * http_request_getEntireEntity (HttpRequest *instance);

void http_request_setResponseHeader (const HttpRequest *request, const char *key, const char *value);
void http_request_setResponseHeaderData (const HttpRequest *request, const char *key, const char *value, int valueLen);

void http_request_setHttpStatus (HttpRequest *request, int status, const char *description);

bool http_request_finishStatus (const HttpRequest *request, int status);

bool http_request_headersSent (const HttpRequest *request);

hshTiterator * http_request_getRequestHeaderIterator (const HttpRequest *request);

#endif
