Revision 1.1 |
Revision 1.4 |
# ifndef HTTP_MESSAGE_H
# define HTTP_MESSAGE_H
|
#ifndef HTTP_MESSAGE_H
#define HTTP_MESSAGE_H
|
|
|
# include "defines.h"
|
#include "defines.h"
|
typedef struct http_message {
|
typedef struct http_message {
|
int fdp; /* port fd * (i.e. pending request) */
int fdd; /* data fd */
|
int fdp; /* port fd * (i.e. pending request) */
int fdd; /* data fd */
|
|
|
int per_thread; /* 1 if per_thread handler; else 0 (i.e. POOL) */
|
int simple; /* simple request (i.e. no HTTP/x.y on request line) */
|
|
int ka_status; /* keepalive status; see defines.h */
int ka_count; /* keepalive count */
time_t ka_timeout; /* when ka expires */
|
|
|
int simple; /* simple request */
int ka_status; /* keepalive status; see defines.h */
int ka_count; /* keepalive count */
|
char* http_version;
int hv_major;
int hv_minor;
|
time_t ka_timeout; /* when ka expires */
|
|
|
|
char* http_version;
int hv_major;
int hv_minor;
|
/* p_ for association with port fd (pending request) */
char* p_header_end;
char* p_pos;
|
|
int p_uri_len;
//char* p_uri_begin;
//char* p_uri_end;
char p_uri[ MAX_REQ_URI_LEN+1 ];
char p_pathname[ MAX_PATH_LENGTH ];
char p_buf[ MAX_BUF_SIZE ];
int p_method; /* enum method */
char* p_buf_head; /* begin of unused buffer portion */
int p_buf_left; /* bytes of buf left for reading the request */
int p_buf_read; /* return val of each recv */
char* p_entity_body; /* begin of the entity body */
// probably not needed. rm later.
int p_eof; /* if [pth_]read/recv returned 0, set this to 1 */
|
|
|
/* p_ for association with port fd (pending request) */
char* p_header_end;
char* p_pos;
char* p_uri_begin;
char* p_uri_end;
|
/* r_ for reply message */
char r_buf[ MAX_BUF_SIZE ];
char *r_mimes;
// size_t r_filesize;
unsigned long r_filesize;
|
char p_uri[ PATH_MAX ];
char p_pathname[ MAX_PATH_LENGTH ];
char p_buf[ MAX_BUF_SIZE ];
int p_method; /* enum method */
char* p_buf_head; /* begin of unused buffer portion */
int p_buf_left; /* bytes of buf left for reading the request */
int p_buf_read; /* return val of each recv */
char* p_entity_body; /* begin of the entity body */
// probably not needed. rm later.
int p_eof; /* if [pth_]read/recv returned 0, set this to 1 */
|
|
|
|
/* r_ for reply message */
|
int status;
|
char r_buf[ MAX_BUF_SIZE ];
char *r_mimes;
// size_t r_filesize;
unsigned long r_filesize;
|
|
|
|
int status;
|
int filetype;
|
|
|
int filetype;
|
/* header options */
|
|
char *if_modified_since; /* If-Modified-Since */
time_t last_modified; /* Last-modified: */
|
|
|
/* header options */
char *if_modified_since; /* If-Modified-Since */
time_t last_modified; /* Last-modified: */
|
char *content_type;
char *content_length;
int is_cgi;
|
|
|
char *content_type;
char *content_length;
int is_cgi;
|
char *header_user_agent;
char *header_referer;
char *header_line; // added
|
|
|
char *header_user_agent;
char *header_referer;
char *header_line; // added
|
|
} msg; enum Method {
|
} msg; enum Method {
|
M_OPTIONS,
M_GET,
M_HEAD,
M_POST,
M_PUT,
M_DELETE,
M_TRACE,
M_CONNECT,
M_EXTENTION
|
M_OPTIONS,
M_GET,
M_HEAD,
M_POST,
M_PUT,
M_DELETE,
M_TRACE,
M_CONNECT,
M_EXTENTION
|
}; enum ReqStatus {
|
}; enum ReqStatus {
|
START_LINE,
NO_CRLF,
ONE_CRLF,
TWO_CRLF,
BODY_WRITE,
BODY_READ,
DONE,
DEAD
|
START_LINE,
NO_CRLF,
ONE_CRLF,
TWO_CRLF,
BODY_WRITE,
BODY_READ,
DONE,
DEAD
|
}; enum FileType {
|
}; enum FileType {
|
HTML,
TXT,
DATA
|
HTML,
TXT,
DATA
|
}; # endif /* HTTP_MESSAGE_H */
|
}; # endif /* HTTP_MESSAGE_H */
|