--- parser3/src/include/pa_http.h 2020/10/10 06:08:36 1.20 +++ parser3/src/include/pa_http.h 2020/10/11 23:25:09 1.23 @@ -8,7 +8,7 @@ #ifndef PA_HTTP_H #define PA_HTTP_H -#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.20 2020/10/10 06:08:36 moko Exp $" +#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.23 2020/10/11 23:25:09 moko Exp $" #include "pa_vstring.h" #include "pa_vint.h" @@ -27,7 +27,7 @@ struct File_read_http_result { }; #endif -class ResponseHeaders { +class HTTP_Headers { public: class Header { public: @@ -48,7 +48,7 @@ public: String::Body content_type; uint64_t content_length; - ResponseHeaders() : content_type(""), content_length(0){} + HTTP_Headers() : content_type(""), content_length(0){} bool add_header(const char *line); @@ -81,13 +81,22 @@ public: HTTPD_Connection(int asock, const char *addr) : sock(asock), remote_addr(addr), request(NULL){}; - Array &headers(); + Array &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; + } + void read_header(); size_t read_post(char *, size_t); size_t send_body(const void *buf, size_t size); @@ -95,7 +104,7 @@ public: class HTTPD_Server : public PA_Allocated { public: - static int bind(const char *host, int port); + static int bind(const char *host_port); static HTTPD_Connection *accept(int sock, int timeout_value); };