--- parser3/src/include/pa_http.h 2020/10/10 06:08:36 1.20 +++ parser3/src/include/pa_http.h 2020/10/14 11:24:46 1.26 @@ -8,7 +8,7 @@ #ifndef PA_HTTP_H #define PA_HTTP_H -#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.20 2020/10/10 06:08:36 moko Exp $" +#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.26 2020/10/14 11:24:46 moko Exp $" #include "pa_vstring.h" #include "pa_vint.h" @@ -27,7 +27,7 @@ struct File_read_http_result { }; #endif -class ResponseHeaders { +class HTTP_Headers { public: class Header { public: @@ -48,7 +48,7 @@ public: String::Body content_type; uint64_t content_length; - ResponseHeaders() : content_type(""), content_length(0){} + HTTP_Headers() : content_type(""), content_length(0){} bool add_header(const char *line); @@ -79,24 +79,34 @@ public: const char *remote_addr; HTTPD_request *request; - HTTPD_Connection(int asock, const char *addr) : sock(asock), remote_addr(addr), request(NULL){}; + HTTPD_Connection() : sock(-1), remote_addr(NULL), request(NULL){} + ~HTTPD_Connection(); - Array &headers(); + Array &headers(); const char *method(); const char *uri(); const char *content_type(); uint64_t content_length(); + const char *query(){ + if(uri()){ + const char *result=strchr(uri(), '?'); + if(result++ && *result) + return result; + } + return NULL; + } + + bool accept(int, int); void read_header(); size_t read_post(char *, size_t); - size_t send_body(const void *buf, size_t size); + size_t send_body(const void *, size_t); }; class HTTPD_Server : public PA_Allocated { public: - static int bind(const char *host, int port); - static HTTPD_Connection *accept(int sock, int timeout_value); + static int bind(const char *); }; #endif