--- parser3/src/include/pa_http.h 2020/10/10 09:05:42 1.21 +++ parser3/src/include/pa_http.h 2020/12/15 10:25:16 1.28 @@ -8,7 +8,7 @@ #ifndef PA_HTTP_H #define PA_HTTP_H -#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.21 2020/10/10 09:05:42 moko Exp $" +#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.28 2020/12/15 10:25:16 moko Exp $" #include "pa_vstring.h" #include "pa_vint.h" @@ -79,7 +79,8 @@ 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(); @@ -88,15 +89,31 @@ public: 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); + enum HTTPD_MODE { + SEQUENTIAL, + PARALLEL, + MULTITHREADED + } static mode; + + static void set_mode(const String&); + static int bind(const char *); }; #endif