Diff for /parser3/src/include/pa_http.h between versions 1.18 and 1.35

version 1.18, 2017/01/23 09:33:02 version 1.35, 2024/11/04 03:53:25
Line 1 Line 1
 /** @file  /** @file
         Parser: commonly used functions.          Parser: commonly used functions.
   
         Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)          Copyright (c) 2001-2024 Art. Lebedev Studio (http://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>
   #define socklen_t int
   #else
   #define closesocket close
   #define INVALID_SOCKET -1
   typedef int SOCKET;
   #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 27  struct File_read_http_result { Line 36  struct File_read_http_result {
 };   }; 
 #endif  #endif
   
 class ResponseHeaders {  class HTTP_Headers {
 public:  public:
         class Header {          class Header {
         public:          public:
Line 48  public: Line 57  public:
         String::Body content_type;          String::Body content_type;
         uint64_t content_length;          uint64_t content_length;
   
         ResponseHeaders() : content_type(""), content_length(0){}          HTTP_Headers() : content_type(""), content_length(0){}
   
         bool add_header(const char *line);          bool add_header(const char *line);
   
Line 60  public: Line 69  public:
   
 };  };
   
   /*** http part ***/
   
 Table* parse_cookies(Request& r, Table *cookies);  Table* parse_cookies(Request& r, Table *cookies);
 void tables_update(HashStringValue& tables, const String::Body name, const String& value);  void tables_update(HashStringValue& tables, const String::Body name, const String& value);
   
Line 67  char *pa_http_safe_header_name(const cha Line 78  char *pa_http_safe_header_name(const cha
   
 File_read_http_result pa_internal_file_read_http(Request& r, const String& file_spec, bool as_text, HashStringValue *options=0, bool transcode_text_result=true);  File_read_http_result pa_internal_file_read_http(Request& r, const String& file_spec, bool as_text, HashStringValue *options=0, bool transcode_text_result=true);
   
   /*** httpd part ***/
   
   //#define HTTPD_DEBUG
   
   class HTTPD_request;
   
   class HTTPD_Connection : public PA_Allocated {
   public:
           SOCKET sock;
           const char *remote_addr;
           HTTPD_request *request;
   
           HTTPD_Connection() : sock(INVALID_SOCKET), remote_addr(NULL), request(NULL){}
           ~HTTPD_Connection();
   
           Array<HTTP_Headers::Header> &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(SOCKET, int);
           bool read_header();
           size_t read_post(char *, size_t);
           size_t send_body(const void *, size_t);
   };
   
   class HTTPD_Server : public PA_Allocated {
   public:
           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

Removed from v.1.18  
changed lines
  Added in v.1.35


E-mail: