--- parser3/src/include/pa_http.h 2020/10/10 09:05:42 1.21 +++ parser3/src/include/pa_http.h 2020/12/16 15:04:47 1.31 @@ -1,14 +1,14 @@ /** @file Parser: commonly used functions. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #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.31 2020/12/16 15:04:47 moko Exp $" #include "pa_vstring.h" #include "pa_vint.h" @@ -71,6 +71,8 @@ File_read_http_result pa_internal_file_r /*** httpd part ***/ +//#define HTTPD_DEBUG + class HTTPD_request; class HTTPD_Connection : public PA_Allocated { @@ -79,7 +81,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 +91,31 @@ public: const char *content_type(); uint64_t content_length(); - void read_header(); + const char *query(){ + if(uri()){ + const char *result=strchr(uri(), '?'); + if(result++ && *result) + return result; + } + return NULL; + } + + bool accept(int, int); + bool 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