1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #ifndef _HTTPSERV_H_
- #define _HTTPSERV_H_
- #include "connection.h"
- #include "headers.h"
- #include "nswasabi/ReferenceCounted.h"
- class JNL_HTTPServ : public ReferenceCountedBase<JNL_HTTPServ>
- {
- public:
- JNL_HTTPServ(JNL_Connection *con=NULL);
- ~JNL_HTTPServ();
- int run();
- const char *geterrorstr() { return m_errstr;}
-
- const char *get_request_file();
- const char *get_request_parm(const char *parmname);
- const char *getallheaders() { return recvheaders.GetAllHeaders(); }
- const char *getheader(const char *headername);
- const char *get_method() { return m_method; };
- void set_reply_string(const char *reply_string);
- void add_reply_header(const char *header);
- void send_reply() { m_reply_ready=1; }
-
- int bytes_inqueue() { if (m_state == 3 || m_state == -1 || m_state ==4) return (int)m_con->send_bytes_in_queue(); else return 0; }
- int bytes_cansend() { if (m_state == 3) return (int)m_con->send_bytes_available(); else return 0; }
- void write_bytes(char *bytes, int length) { m_con->send(bytes,length); }
- void close(int quick) { m_con->close(quick); m_state=4; }
- JNL_Connection *get_con() { return m_con; }
- void reset();
- int get_http_version() { return http_ver; }
- int get_keep_alive() { return keep_alive; }
- protected:
- void seterrstr(const char *str) { if (m_errstr) free(m_errstr); m_errstr=_strdup(str); }
- int m_reply_ready;
- int m_state;
- int http_ver;
- int keep_alive;
- char *m_errstr;
- char *m_reply_headers;
- char *m_reply_string;
- JNL_Headers recvheaders;
- char *m_recv_request;
- char *m_method;
- JNL_Connection *m_con;
- };
- #endif
|