--- parser3/src/include/pa_http.h 2020/12/16 10:45:09 1.30 +++ parser3/src/include/pa_http.h 2024/11/04 03:53:25 1.35 @@ -1,14 +1,14 @@ /** @file Parser: commonly used functions. - Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef PA_HTTP_H #define PA_HTTP_H -#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.30 2020/12/16 10:45:09 moko Exp $" +#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.35 2024/11/04 03:53:25 moko Exp $" #include "pa_vstring.h" #include "pa_vint.h" @@ -20,6 +20,15 @@ #define HTTP_COOKIES_NAME "cookies" +#ifdef _MSC_VER +#include +#define socklen_t int +#else +#define closesocket close +#define INVALID_SOCKET -1 +typedef int SOCKET; +#endif + #ifndef DOXYGEN struct File_read_http_result { char *str; size_t length; @@ -71,15 +80,17 @@ File_read_http_result pa_internal_file_r /*** httpd part ***/ +//#define HTTPD_DEBUG + class HTTPD_request; class HTTPD_Connection : public PA_Allocated { public: - int sock; + SOCKET sock; const char *remote_addr; HTTPD_request *request; - HTTPD_Connection() : sock(-1), remote_addr(NULL), request(NULL){} + HTTPD_Connection() : sock(INVALID_SOCKET), remote_addr(NULL), request(NULL){} ~HTTPD_Connection(); Array &headers(); @@ -98,7 +109,7 @@ public: return NULL; } - bool accept(int, int); + bool accept(SOCKET, int); bool read_header(); size_t read_post(char *, size_t); size_t send_body(const void *, size_t); @@ -111,9 +122,10 @@ public: PARALLEL, MULTITHREADED } static mode; + static const char *port; static void set_mode(const String&); - static int bind(const char *); + static SOCKET bind(const char *); }; #endif