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

📄 http.h

📁 pwlib源码库
💻 H
📖 第 1 页 / 共 5 页
字号:
  // Overrides from class PHTTPAuthority.    /** Get the realm or name space for the user authorisation name and       password as required by the basic authorisation system of HTTP/1.0.       @return       String for the authorisation realm name.     */    virtual PString GetRealm(      const PHTTPRequest & request   // Request information.    ) const;    /** Validate the user and password provided by the remote HTTP client for       the realm specified by the class instance.       @return       TRUE if the user and password are authorised in the realm.     */    virtual BOOL Validate(      const PHTTPRequest & request,  // Request information.      const PString & authInfo       // Authority information string.    ) const;    /** Determine if the authirisation is to be applied. This could be used to       distinguish between net requiring authorisation and requiring autorisation       but having no password.       The default behaviour is to return TRUE.       @return       TRUE if the authorisation in the realm is to be applied.     */    virtual BOOL IsActive() const;    /** Get the user name allocated to this simple authorisation.       @return       String for the authorisation user name.     */    void AddUser(      const PString & username,   // Username that this object wiull authorise.      const PString & password    // Password for the above username.    );  protected:    PString realm;    PStringToString users;};//////////////////////////////////////////////////////////////////////////////// PHTTPResource/** This object describes a HyperText Transport Protocol resource. A tree of   these resources are available to the #PHTTPSocket# class. */class PHTTPResource : public PObject{  PCLASSINFO(PHTTPResource, PObject)  protected:    PHTTPResource(      const PURL & url               // Name of the resource in URL space.    );    PHTTPResource(      const PURL & url,              // Name of the resource in URL space.      const PHTTPAuthority & auth    // Authorisation for the resource.    );    PHTTPResource(      const PURL & url,              // Name of the resource in URL space.      const PString & contentType    // MIME content type for the resource.    );    PHTTPResource(      const PURL & url,              // Name of the resource in URL space.      const PString & contentType,   // MIME content type for the resource.      const PHTTPAuthority & auth    // Authorisation for the resource.    );    // Create a new HTTP Resource.  public:    virtual ~PHTTPResource();    // Destroy the HTTP Resource.  // New functions for class.    /** Get the URL for this resource.       @return       The URL for this resource.     */    const PURL & GetURL() const { return baseURL; }    /** Get the current content type for the resource.       @return       string for the current MIME content type.     */    const PString & GetContentType() const { return contentType; }    /** Get the current authority for the resource.       @return       Pointer to authority or NULL if unrestricted.     */    PHTTPAuthority * GetAuthority() const { return authority; }    /** Set the current authority for the resource.     */    void SetAuthority(      const PHTTPAuthority & auth    );    /** Set the current authority for the resource to unrestricted.     */    void ClearAuthority();    /** Get the current hit count for the resource. This is the total number of       times the resource was asked for by a remote client.       @return       Hit count for the resource.     */    DWORD GetHitCount() const { return hitCount; }    void ClearHitCount() { hitCount = 0; }    // Clear the hit count for the resource.    /** Handle the GET command passed from the HTTP socket.       The default action is to check the authorisation for the resource and       call the virtuals #LoadHeaders()# and #OnGETData()# to get       a resource to be sent to the socket.       @return       TRUE if the connection may persist, FALSE if the connection must close.       If there is no ContentLength field in the response, this value must       be FALSE for correct operation.     */    virtual BOOL OnGET(      PHTTPServer & server,       // HTTP server that received the request      const PURL & url,           // Universal Resource Locator for document.      const PMIMEInfo & info,     // Extra MIME information in command.      const PHTTPConnectionInfo & conInfo    );    /**Send the data associated with a GET command.       The default action calls #SendData()#.       @return       TRUE if the connection may persist, FALSE if the connection must close.       If there is no ContentLength field in the response, this value must       be FALSE for correct operation.    */    virtual BOOL OnGETData(      PHTTPServer & server,      const PURL & url,      const PHTTPConnectionInfo & connectInfo,      PHTTPRequest & request    );    /** Handle the HEAD command passed from the HTTP socket.       The default action is to check the authorisation for the resource and       call the virtual #LoadHeaders()# to get the header information to       be sent to the socket.       @return       TRUE if the connection may persist, FALSE if the connection must close       If there is no ContentLength field in the response, this value must       be FALSE for correct operation.     */    virtual BOOL OnHEAD(      PHTTPServer & server,       // HTTP server that received the request      const PURL & url,           // Universal Resource Locator for document.      const PMIMEInfo & info,     // Extra MIME information in command.      const PHTTPConnectionInfo & conInfo    );    /** Handle the POST command passed from the HTTP socket.       The default action is to check the authorisation for the resource and       call the virtual #Post()# function to handle the data being       received.       @return       TRUE if the connection may persist, FALSE if the connection must close       If there is no ContentLength field in the response, this value must       be FALSE for correct operation.     */    virtual BOOL OnPOST(      PHTTPServer & server,         // HTTP server that received the request      const PURL & url,             // Universal Resource Locator for document.      const PMIMEInfo & info,       // Extra MIME information in command.      const PStringToString & data, // Variables in the POST data.      const PHTTPConnectionInfo & conInfo    );    /**Send the data associated with a POST command.       The default action calls #Post()#.       @return       TRUE if the connection may persist, FALSE if the connection must close.       If there is no ContentLength field in the response, this value must       be FALSE for correct operation.    */    virtual BOOL OnPOSTData(      PHTTPRequest & request,      const PStringToString & data // Variables in the POST data.    );    /** Check to see if the resource has been modified since the date       specified.       @return       TRUE if has been modified since.     */    virtual BOOL IsModifiedSince(      const PTime & when    // Time to see if modified later than    );    /** Get a block of data (eg HTML) that the resource contains.       @return       Status of load operation.     */    virtual BOOL GetExpirationDate(      PTime & when          // Time that the resource expires    );    /** Create a new request block for this type of resource.       The default behaviour is to create a new PHTTPRequest instance.       @return       Pointer to instance of PHTTPRequest descendant class.     */    virtual PHTTPRequest * CreateRequest(      const PURL & url,                   // Universal Resource Locator for document.      const PMIMEInfo & inMIME,           // Extra MIME information in command.      const PMultipartFormInfoArray & multipartFormInfo,      PHTTPServer & socket    );    /** Get the headers for block of data (eg HTML) that the resource contains.       This will fill in all the fields of the <CODE>outMIME</CODE> parameter       required by the resource and return the status for the load.       @return       TRUE if all OK, FALSE if an error occurred.     */    virtual BOOL LoadHeaders(      PHTTPRequest & request    // Information on this request.    ) = 0;    /**Send the data associated with a command.       The default action is to call the virtual #LoadData()# to get a       resource to be sent to the socket.    */    virtual void SendData(      PHTTPRequest & request    );    /** Get a block of data that the resource contains.       The default behaviour is to call the #LoadText()# function and       if successful, call the #OnLoadedText()# function.       @return       TRUE if there is still more to load.     */    virtual BOOL LoadData(      PHTTPRequest & request,    // Information on this request.      PCharArray & data          // Data used in reply.    );    /** Get a block of text data (eg HTML) that the resource contains.       The default behaviour is to assert, one of #LoadText()# or       #LoadData()# functions must be overridden for correct operation.       @return       String for loaded text.     */    virtual PString LoadText(      PHTTPRequest & request    // Information on this request.    );    /** This is called after the text has been loaded and may be used to       customise or otherwise mangle a loaded piece of text. Typically this is       used with HTML responses.       The default action for this function is to do nothing.     */    virtual void OnLoadedText(      PHTTPRequest & request,    // Information on this request.      PString & text             // Data used in reply.    );    /** Get a block of data (eg HTML) that the resource contains.       The default action for this function is to do nothing and return       success.       @return       TRUE if the connection may persist, FALSE if the connection must close     */    virtual BOOL Post(      PHTTPRequest & request,       // Information on this request.      const PStringToString & data, // Variables in the POST data.      PHTML & replyMessage          // Reply message for post.    );  protected:    /** See if the resource is authorised given the mime info     */    virtual BOOL CheckAuthority(      PHTTPServer & server,               // Server to send response to.      const PHTTPRequest & request,       // Information on this request.      const PHTTPConnectionInfo & conInfo // Information on the connection    );    static BOOL CheckAuthority(                   PHTTPAuthority & authority,                      PHTTPServer & server,               const PHTTPRequest & request,        const PHTTPConnectionInfo & connectInfo    );    /** common code for GET and HEAD commands */    virtual BOOL OnGETOrHEAD(      PHTTPServer & server,       // HTTP server that received the request      const PURL & url,           // Universal Resource Locator for document.      const PMIMEInfo & info,     // Extra MIME information in command.      const PHTTPConnectionInfo & conInfo,      BOOL  IsGet    );    /// Base URL for the resource, may accept URLS with a longer hierarchy    PURL             baseURL;    /// MIME content type for the resource    PString          contentType;    /// Authorisation method for the resource    PHTTPAuthority * authority;    /// COunt of number of times resource was accessed.    volatile DWORD   hitCount;};//////////////////////////////////////////////////////////////////////////////// PHTTPString/** This object describes a HyperText Transport Protocol resource which is a   string kept in memory. For instance a pre-calculated HTML string could be   set in this type of resource. */class PHTTPString : public PHTTPResource{  PCLASSINFO(PHTTPString, PHTTPResource)  public:    /** Contruct a new simple string resource for the HTTP space. If no MIME       content type is specified then a default type is "text/html".     */    PHTTPString(      const PURL & url             // Name of the resource in URL space.    );    PHTTPString(      const PURL & url,            // Name of the resource in URL space.      const PHTTPAuthority & auth  // Authorisation for the resource.    );    PHTTPString(      const PURL & url,            // Name of the resource in URL space.      const PString & str          // String to return in this resource.    );

⌨️ 快捷键说明

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