--- parser3/src/include/pa_request_info.h 2012/03/16 09:24:10 1.7 +++ parser3/src/include/pa_request_info.h 2020/12/15 17:10:32 1.16 @@ -1,14 +1,14 @@ /** @file Parser: request info class decl. - Copyright (c) 2001-2012 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_REQUEST_INFO_H #define PA_REQUEST_INFO_H -#define IDENT_PA_REQUEST_INFO_H "$Id: pa_request_info.h,v 1.7 2012/03/16 09:24:10 moko Exp $" +#define IDENT_PA_REQUEST_INFO_H "$Id: pa_request_info.h,v 1.16 2020/12/15 17:10:32 moko Exp $" /// some information from web server class Request_info { @@ -24,12 +24,36 @@ public: const char* cookie; char** argv; - int args_skip; bool mail_received; //@} //@{ these are filed by Request class itself: user's post data const char* post_data; size_t post_size; //@} + + // see feature #1116 for details + bool can_have_body(){ + return + method + && strcasecmp(method, "GET") != 0 + && strcasecmp(method, "HEAD") != 0 + && strcasecmp(method, "TRACE") != 0; + } + + static const char* strip_absolute_uri(const char *auri){ + if(!auri || *auri == '/') + return auri; + + // extractring https?://site.name prefix allowed by http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 + + if(!pa_strncasecmp(auri, "http://")) + auri+=7; + else if(!pa_strncasecmp(auri, "https://")) + auri+=8; + else + return auri; + for(; *auri && *auri != '/'; auri++); + return auri; + } }; #endif