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

1.2       paf         1: /** @file
                      2:        Parser: request info class decl.
                      3: 
1.9       moko        4:        Copyright (c) 2001-2015 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.12    ! moko       11: #define IDENT_PA_REQUEST_INFO_H "$Id: pa_request_info.h,v 1.11 2016/11/25 23:35:44 moko Exp $"
1.2       paf        12: 
                     13: /// some information from web server
                     14: class Request_info {
                     15: public:
                     16:        //@{ these filled by Request class user
                     17:        const char* document_root;
                     18:        const char* path_translated;
                     19:        const char* method;
                     20:        const char* query_string;
                     21:        const char* uri;
                     22:        const char* content_type;
                     23:        size_t content_length;
                     24:        const char* cookie;
1.6       misha      25:        
                     26:        char** argv;
                     27:        int args_skip;
1.2       paf        28:        bool mail_received;
                     29:        //@}
                     30:        //@{ these are filed by Request class itself: user's post data
                     31:        const char* post_data;  size_t post_size;
                     32:        //@}
1.8       misha      33: 
                     34:        // misha@ Probably it's a good idea to move this method into targets, but de facto the only POST and PUT can have the body and all targets should support it
                     35:        bool can_have_body(){
                     36:                return
                     37:                        method
                     38:                        && (
                     39:                                strcasecmp(method, "POST") == 0
                     40:                                || strcasecmp(method, "PUT") == 0
                     41:                        );
                     42:        }
1.10      moko       43: 
1.11      moko       44:        static const char* strip_absolute_uri(const char *auri){
1.12    ! moko       45:                if(!auri || *auri == '/')
1.10      moko       46:                        return auri;
                     47: 
                     48:                // extractring https?://site.name prefix allowed by http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
                     49: 
                     50:                if(!pa_strncasecmp(auri, "http://"))
                     51:                        auri+=7;
                     52:                else if(!pa_strncasecmp(auri, "https://"))
                     53:                        auri+=8;
                     54:                else
                     55:                        return auri;
                     56:                for(; *auri && *auri != '/'; auri++);
                     57:                return auri;
                     58:        }
1.2       paf        59: };
                     60: 
                     61: #endif

E-mail: