Annotation of parser3/src/include/pa_request_info.h, revision 1.17

1.2       paf         1: /** @file
                      2:        Parser: request info class decl.
                      3: 
1.16      moko        4:        Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com)
1.2       paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
                      8: #ifndef PA_REQUEST_INFO_H
                      9: #define PA_REQUEST_INFO_H
                     10: 
1.17    ! moko       11: #define IDENT_PA_REQUEST_INFO_H "$Id: pa_request_info.h,v 1.16 2020/12/15 17:10:32 moko Exp $"
        !            12: 
        !            13: // include
        !            14: 
        !            15: #include "pa_config_includes.h"
1.2       paf        16: 
                     17: /// some information from web server
                     18: class Request_info {
                     19: public:
                     20:        //@{ these filled by Request class user
                     21:        const char* document_root;
                     22:        const char* path_translated;
                     23:        const char* method;
                     24:        const char* query_string;
                     25:        const char* uri;
                     26:        const char* content_type;
                     27:        size_t content_length;
                     28:        const char* cookie;
1.6       misha      29:        
                     30:        char** argv;
1.2       paf        31:        bool mail_received;
                     32:        //@}
                     33:        //@{ these are filed by Request class itself: user's post data
                     34:        const char* post_data;  size_t post_size;
                     35:        //@}
1.8       misha      36: 
1.13      moko       37:        // see feature #1116 for details
1.8       misha      38:        bool can_have_body(){
                     39:                return
                     40:                        method
1.13      moko       41:                        && strcasecmp(method, "GET") != 0
                     42:                        && strcasecmp(method, "HEAD") != 0
                     43:                        && strcasecmp(method, "TRACE") != 0;
1.8       misha      44:        }
1.10      moko       45: 
1.11      moko       46:        static const char* strip_absolute_uri(const char *auri){
1.12      moko       47:                if(!auri || *auri == '/')
1.10      moko       48:                        return auri;
                     49: 
                     50:                // extractring https?://site.name prefix allowed by http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
                     51: 
                     52:                if(!pa_strncasecmp(auri, "http://"))
                     53:                        auri+=7;
                     54:                else if(!pa_strncasecmp(auri, "https://"))
                     55:                        auri+=8;
                     56:                else
                     57:                        return auri;
                     58:                for(; *auri && *auri != '/'; auri++);
                     59:                return auri;
                     60:        }
1.17    ! moko       61: 
        !            62:        Request_info() {
        !            63:                memset(this, 0, sizeof(*this)); // OK as Request_info is POD
        !            64:        }
1.2       paf        65: };
                     66: 
                     67: #endif

E-mail: