⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parseutil.h

📁 UPnP的SDK源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
    bool setTag( const char* newLangTag );    public:    xstring lang;};// cache-control infoclass CacheDirective : public HttpHeaderValue{public:    enum DirectiveType { UNKNOWN,        NO_CACHE,        NO_CACHE_FIELDS,        // use 'fields' list        NO_STORE,        MAX_AGE,                // use 'deltaSeconds'; secondsValid always true        MAX_STALE,              // 'secondsValid' and 'deltaSeconds'        MIN_FRESH,              // use 'deltaSeconds'; secondsValid always true        NO_TRANSFORM, ONLY_IF_CACHED, PUBLIC,        PRIVATE,                // use 'fields'        MUST_REVALIDATE,        PROXY_REVALIDATE,        S_MAXAGE,               // use 'deltaSeconds'; secondsValid always true        EXTENSION               // use 'extType', 'extensionName', 'extensionValue'        };            enum ExtensionType { IDENTIFIER, QUOTED_STRING };            public:    CacheDirective()    { }        void toString( xstring& s );    void load( Tokenizer& scanner );    public:    DirectiveType type;        // list of 'IdentifierValue'    //CommaSeparatedList fields;    xstring fields; // quoted, comma-separated identifiers        HttpNumber deltaSeconds;        // if true, 'deltaSeconds' is valid; else ignore 'deltaSeconds'    bool secondsValid;          ExtensionType extType;    xstring extensionName;    xstring extensionValue;    private:    bool readFields( Tokenizer& scanner );    void readDeltaSeconds( Tokenizer& scanner, bool optional );    void readExtension( Tokenizer& scanner );};// HttpDateValueclass HttpDateValue : public HttpHeaderValue{public:    HttpDateValue()    { }        void load( Tokenizer& scanner );    void toString( xstring& s );    tm gmtDateTime;};// HttpDateOrSecondsclass HttpDateOrSeconds : public HttpHeaderValue{public:    HttpDateOrSeconds()    { }        void load( Tokenizer& scanner );    void toString( xstring& s );        bool isSeconds;    int seconds;    tm gmtDateTime;};// HostPortValueclass HostPortValue : public HttpHeaderValue{public:    HostPortValue()    { }    ~HostPortValue()    { }    void load( Tokenizer& scanner );    void toString( xstring& s );        bool setHostPort( const char* hostName, unsigned short port );    void getHostPort( sockaddr_in* addr );private:    hostport_type hostport;    xstring tempBuf;};// uri valueclass UriType : public HttpHeaderValue{public:    UriType()    { }    void load( Tokenizer& scanner );    void toString( xstring& s );    bool setUri( const char* newUriValue );    const char* getUri() const;    // address will have IP address and port    // returns -1 on error, 0 on success    int getIPAddress( OUT sockaddr_in& address );    uri_type uri;    private:    xstring tempBuf;    // store string for uri_type};class NTType : public HttpHeaderValue{public:    enum NTValue { UNKNOWN, UPNP_ROOTDEVICE, UUID, URN, UPNP_EVENT };    public:    NTType()    { }        void load( Tokenizer& scanner );    void toString( xstring& s );        NTValue type;    xstring value;};// NTSType -- notification subtypeclass NTSType : public HttpHeaderValue{public:    enum NTSValue { UPNP_PROPCHANGE, SSDP_ALIVE, SSDP_BYEBYE };public:    NTSType()    { }        void load( Tokenizer& scanner );    void toString( xstring& s );    public:    NTSValue value;};// RawHeaderValue - matches any header valueclass RawHeaderValue : public HttpHeaderValue{public:    RawHeaderValue()    { }        void load( Tokenizer& scanner );    void toString( xstring& s );public:     xstring value;};// when header name is not processed (i.e. HDR_UNKONWN),//  raw header name and value saved// note: trailing crlf not consumedclass UnknownHeader : public HttpHeaderValue{public:    UnknownHeader()    { }        void load( Tokenizer& scanner );    void toString( xstring& s );        xstring name;    xstring value;};// ========================================================// first line of a requestclass HttpRequestLine{public:    HttpRequestLine()    { }        virtual ~HttpRequestLine()    { }    void toString( xstring& s );    void load( Tokenizer& scanner );    //  void setValue( IN UpnpMethodType umethod, IN const char* uristr,//      IN int majorVers=1, IN int minorVers = 1 );public:     UpnpMethodType method;    UriType uri;        // if pathIsStar==false, this contains url    bool pathIsStar;    // if true, path='*'; uri is ignored    int majorVersion;    int minorVersion;};/////////// first line of responseclass HttpResponseLine{public:    HttpResponseLine()    { }        virtual ~HttpResponseLine()    { }    // returns 0 on success; -1 if statCode is unknown    int setValue( int statCode, int majorVers=1, int minorVers=1 );            void toString( xstring& s );    void load( Tokenizer& scanner );    public:    int statusCode;     // response code    xstring reason;     // response code in msg    int majorVersion;   // http major/minor version    int minorVersion;   };///////////// CharsetConverter//class CharsetConverter//{//public:    // read data from//  int read( void* buf, unsigned bufsize ) = 0;//};class HttpMessage;//////////// body of http message// note: entity may or may not be ascii string, but always has//   a null terminator as its last characterclass HttpEntity{public:    enum EntityType { EMPTY, TEXT, TEXT_PTR, FILENAME };    public:    HttpEntity();                           // type = text    HttpEntity( const char* file_name );    // type = file        virtual ~HttpEntity();    int append( const char* data, unsigned datalen );    void appendDone();        int getEntityLen() const;    const void* getEntity();    EntityType getType() const;    const char* getFileName() const;        unsigned getSizeIncrement() const;    void setSizeIncrement( unsigned incSize );    // valid only if type == TEXT    // after use, caller should destroy entity using free()    void* detachTextEntity();    void attachTextEntity( const void* textEntity, int entityLen );    void setTextPtrEntity( const void* textEntity, int entityLen );    EntityType type;    xstring filename;        private:    enum AppendStateType { IDLE, APPENDING, DONE };     private:    // for type = text    char *entity;    int entitySize;    int allocLen;            // type = filename        AppendStateType appendState;    unsigned sizeInc;    FILE* fp;    friend class HttpMessage;    private:        void init();    void appendInit();    void increaseSizeBy( unsigned newSize );};///////////////////////////////// entire http messageclass HttpMessage{public:    HttpMessage()    { }    HttpMessage( const char* filename )        : entity( filename )    { }    virtual ~HttpMessage();        void loadRequest( Tokenizer& scanner, CharReader* reader );    void loadResponse( Tokenizer& scanner, CharReader* reader,        UpnpMethodType requestMethod );            // returns    // 0: success    // -1: std error; check errno    // or HTTP_E_ error codes    int loadRequest( const char* request );    int loadResponse( const char* response,         UpnpMethodType requestMethod );        int headerCount() const;        void addHeader( int headerType, HttpHeaderValue* value );    void deleteHeader( HttpHeaderNode* headerNode );        HttpHeaderNode* findHeader( int headerType );    HttpHeaderValue* getHeaderValue( int headerType );        HttpHeaderNode* getFirstHeader();    HttpHeaderNode* getNextHeader( HttpHeaderNode* headerNode );    void startLineAndHeadersToString( xstring& s );        /////////////////    // utility funcs    /////////////////        // warning: headerType MUST be a http header type that is associated    //   with RawHeaderValue    void addRawHeader( int headerType, const char* value );        void addContentTypeHeader( const char* type, const char* subtype );    void addServerHeader();    void addLastModifiedHeader( time_t last_mod );    void addUserAgentHeader();    // headerID has values of type HttpDateValue    //  t is time in local timezone    void addDateTypeHeader( int headerID, const time_t& t );    // headerID has value of type HttpNumber    void addNumTypeHeader( int headerID, int num );    // headerID is associated with value CommaSeparatedList<IdentifierValue>    void addIdentListHeader( int headerID, const char* idents[],        int numIdents );public:    HttpRequestLine requestLine;    HttpResponseLine responseLine;    HttpEntity entity;    bool isRequest;    private:    HttpHeaderList headers;private:    // load request/response entity    // tor read request, requestMethod = HTTP_UNKNOWN    // to read response, requestMethod = whatever the request method was    void loadRestOfMessage( Tokenizer& scanner, CharReader* reader,        UpnpMethodType requestMethod );            int messageBodyLen( IN UpnpMethodType requestMethod,        OUT int& length );    int getContentLength();        void readEntityUntilClose( Tokenizer& scanner );    int readEntityUsingLength( Tokenizer& scanner, int length );    void readEncodedEntity( Tokenizer& scanner );};#endif /* GENLIB_NET_HTTP_PARSEUTIL_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -