|
|
| version 1.26, 2020/10/14 11:24:46 | version 1.39, 2026/10/16 13:55:16 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: commonly used functions. | Parser: commonly used functions. |
| Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| #ifndef PA_HTTP_H | #ifndef PA_HTTP_H |
| Line 20 | Line 20 |
| #define HTTP_COOKIES_NAME "cookies" | #define HTTP_COOKIES_NAME "cookies" |
| #ifdef _MSC_VER | |
| #include <windows.h> | |
| #endif | |
| #ifndef DOXYGEN | #ifndef DOXYGEN |
| struct File_read_http_result { | struct File_read_http_result { |
| char *str; size_t length; | char *str; size_t length; |
| Line 54 public: | Line 58 public: |
| void clear(){ | void clear(){ |
| headers.clear(); | headers.clear(); |
| content_type=""; | content_type.clear(); |
| content_length=0; | content_length=0; |
| } | } |
| Line 71 File_read_http_result pa_internal_file_r | Line 75 File_read_http_result pa_internal_file_r |
| /*** httpd part ***/ | /*** httpd part ***/ |
| //#define HTTPD_DEBUG | |
| class HTTPD_request; | class HTTPD_request; |
| class HTTPD_Connection : public PA_Allocated { | class HTTPD_Connection : public PA_Allocated { |
| public: | public: |
| int sock; | SOCKET sock; |
| const char *remote_addr; | const char *remote_addr; |
| HTTPD_request *request; | HTTPD_request *request; |
| HTTPD_Connection() : sock(-1), remote_addr(NULL), request(NULL){} | HTTPD_Connection() : sock(INVALID_SOCKET), remote_addr(NULL), request(NULL){} |
| ~HTTPD_Connection(); | ~HTTPD_Connection(); |
| Array<HTTP_Headers::Header> &headers(); | Array<HTTP_Headers::Header> &headers(); |
| Line 98 public: | Line 104 public: |
| return NULL; | return NULL; |
| } | } |
| bool accept(int, int); | bool accept(SOCKET, int); |
| void read_header(); | bool read_header(); |
| size_t read_post(char *, size_t); | size_t read_post(char *, size_t); |
| size_t send_body(const void *, size_t); | size_t send_body(const void *, size_t); |
| /// bytes received after the request headers, not processed yet | |
| String::C unprocessed(); | |
| /// receives up to size bytes, returns 0 if the connection is closed | |
| size_t receive(char *, size_t); | |
| void set_nodelay(); | |
| void set_send_timeout(int timeout_secs); | |
| }; | }; |
| class HTTPD_Server : public PA_Allocated { | class HTTPD_Server : public PA_Allocated { |
| public: | public: |
| static int bind(const char *); | enum HTTPD_MODE { |
| SEQUENTIAL, | |
| PARALLEL, | |
| MULTITHREADED | |
| } static mode; | |
| static const char *port; | |
| static void set_mode(const String&); | |
| static SOCKET bind(const char *); | |
| }; | }; |
| #endif | #endif |