PixelLightAPI  .
HttpHeader.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: HttpHeader.h                                   *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLCORE_HTTPHEADER_H__
00024 #define __PLCORE_HTTPHEADER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/Container/Array.h"
00032 #include "PLCore/Network/Http/Http.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Classes                                               ]
00043 //[-------------------------------------------------------]
00044 /**
00045 *  @brief
00046 *    HTTP header
00047 */
00048 class HttpHeader {
00049 
00050 
00051     //[-------------------------------------------------------]
00052     //[ Public functions                                      ]
00053     //[-------------------------------------------------------]
00054     public:
00055         /**
00056         *  @brief
00057         *    Constructor
00058         */
00059         PLCORE_API HttpHeader();
00060 
00061         /**
00062         *  @brief
00063         *    Copy constructor
00064         *
00065         *  @param[in] cSource
00066         *    HTTP header
00067         */
00068         PLCORE_API HttpHeader(const HttpHeader &cSource);
00069 
00070         /**
00071         *  @brief
00072         *    Destructor
00073         */
00074         inline ~HttpHeader();
00075 
00076         /**
00077         *  @brief
00078         *    Assignment operator
00079         *
00080         *  @param[in] cSource
00081         *    HTTP header
00082         *
00083         *  @return
00084         *    Reference to this header
00085         */
00086         PLCORE_API HttpHeader &operator =(const HttpHeader &cSource);
00087 
00088         /**
00089         *  @brief
00090         *    Clear header
00091         */
00092         PLCORE_API void Clear();
00093 
00094         /**
00095         *  @brief
00096         *    Check if HTTP header is complete
00097         *
00098         *  @return
00099         *    'true' if header is complete, else 'false'
00100         */
00101         PLCORE_API bool IsComplete() const;
00102 
00103         /**
00104         *  @brief
00105         *    Get header entries
00106         *
00107         *  @return
00108         *    List of header entries
00109         */
00110         inline const Container<String> &GetEntries() const;
00111 
00112         /**
00113         *  @brief
00114         *    Add entry
00115         *
00116         *  @param[in] sEntry
00117         *    Header entry
00118         */
00119         inline void AddEntry(const String &sEntry);
00120 
00121         /**
00122         *  @brief
00123         *    Parse header
00124         *
00125         *  @remarks
00126         *    This function will parse and interpret all header entries. Call this function
00127         *    after you have received the header, then you can access the parsed information
00128         *    via their get-methods (GetSize(), GetContentType(), etc.)
00129         */
00130         PLCORE_API void Parse();
00131 
00132         /**
00133         *  @brief
00134         *    Print header entries to console
00135         *
00136         *  @param[in] bRaw
00137         *    If 'true', all header entries will be printed out, otherwise only those which are known by this implementation
00138         */
00139         PLCORE_API void Print(bool bRaw = false) const;
00140 
00141         /**
00142         *  @brief
00143         *    Get protocol version
00144         *
00145         *  @return
00146         *    HTTP Protocol version
00147         *
00148         *  @remarks
00149         *    To access this information, Parse() has to be called first
00150         */
00151         inline EHttpProtocol GetProtocol() const;
00152 
00153         /**
00154         *  @brief
00155         *    Get message type
00156         *
00157         *  @return
00158         *    HTTP message type (request or response)
00159         *
00160         *  @remarks
00161         *    To access this information, Parse() has to be called first
00162         */
00163         inline EHttpMessageType GetMessageType() const;
00164 
00165         /**
00166         *  @brief
00167         *    Get request
00168         *
00169         *  @return
00170         *    HTTP request type
00171         *
00172         *  @remarks
00173         *    To access this information, Parse() has to be called first
00174         */
00175         inline EHttpRequest GetRequest() const;
00176 
00177         /**
00178         *  @brief
00179         *    Get request as string
00180         *
00181         *  @return
00182         *    HTTP request type
00183         *
00184         *  @remarks
00185         *    To access this information, Parse() has to be called first
00186         */
00187         PLCORE_API String GetRequestString() const;
00188 
00189         /**
00190         *  @brief
00191         *    Get request URL
00192         *
00193         *  @return
00194         *    HTTP request URL
00195         *
00196         *  @remarks
00197         *    To access this information, Parse() has to be called first
00198         */
00199         inline String GetRequestUrl() const;
00200 
00201         /**
00202         *  @brief
00203         *    Get connection type
00204         *
00205         *  @return
00206         *    HTTP connection type
00207         *
00208         *  @remarks
00209         *    To access this information, Parse() has to be called first
00210         */
00211         inline EHttpConnection GetConnectionType() const;
00212 
00213         /**
00214         *  @brief
00215         *    Get status code
00216         *
00217         *  @return
00218         *    Status code
00219         *
00220         *  @remarks
00221         *    To access this information, Parse() has to be called first
00222         */
00223         inline uint32 GetStatusCode() const;
00224 
00225         /**
00226         *  @brief
00227         *    Get status string
00228         *
00229         *  @return
00230         *    Status string
00231         *
00232         *  @remarks
00233         *    To access this information, Parse() has to be called first
00234         */
00235         inline String GetStatusString() const;
00236 
00237         /**
00238         *  @brief
00239         *    Get location
00240         *
00241         *  @return
00242         *    Location
00243         *
00244         *  @remarks
00245         *    To access this information, Parse() has to be called first
00246         */
00247         inline String GetLocation() const;
00248 
00249         /**
00250         *  @brief
00251         *    Get date
00252         *
00253         *  @return
00254         *    Date
00255         *
00256         *  @remarks
00257         *    To access this information, Parse() has to be called first
00258         */
00259         inline String GetDate() const;
00260 
00261         /**
00262         *  @brief
00263         *    Get server signature
00264         *
00265         *  @return
00266         *    Server signature
00267         *
00268         *  @remarks
00269         *    To access this information, Parse() has to be called first
00270         */
00271         inline String GetServer() const;
00272 
00273         /**
00274         *  @brief
00275         *    Get client signature
00276         *
00277         *  @return
00278         *    Client signature
00279         *
00280         *  @remarks
00281         *    To access this information, Parse() has to be called first
00282         */
00283         inline String GetUserAgent() const;
00284 
00285         /**
00286         *  @brief
00287         *    Get authentication type
00288         *
00289         *  @return
00290         *    Authentication type
00291         *
00292         *  @remarks
00293         *    To access this information, Parse() has to be called first
00294         */
00295         inline EHttpAuth GetAuthenticationType() const;
00296 
00297         /**
00298         *  @brief
00299         *    Get authentication realm
00300         *
00301         *  @return
00302         *    Authentication realm
00303         *
00304         *  @remarks
00305         *    To access this information, Parse() has to be called first
00306         */
00307         inline String GetAuthenticationRealm() const;
00308 
00309         /**
00310         *  @brief
00311         *    Get authorization string
00312         *
00313         *  @return
00314         *    Authorization string
00315         *
00316         *  @remarks
00317         *    To access this information, Parse() has to be called first
00318         */
00319         inline String GetAuthorization() const;
00320 
00321         /**
00322         *  @brief
00323         *    Get transfer encoding
00324         *
00325         *  @return
00326         *    Transfer encoding
00327         *
00328         *  @remarks
00329         *    To access this information, Parse() has to be called first
00330         */
00331         inline String GetTransferEncoding() const;
00332 
00333         /**
00334         *  @brief
00335         *    Check if data is transfered "chunked"
00336         *
00337         *  @return
00338         *    'true' if transfer encoding is "chunked", else 'false'
00339         *
00340         *  @remarks
00341         *    To access this information, Parse() has to be called first
00342         */
00343         inline bool IsChunked() const;
00344 
00345         /**
00346         *  @brief
00347         *    Get content length
00348         *
00349         *  @return
00350         *    Content length
00351         *
00352         *  @remarks
00353         *    To access this information, Parse() has to be called first
00354         */
00355         inline uint32 GetContentLength() const;
00356 
00357         /**
00358         *  @brief
00359         *    Get content language
00360         *
00361         *  @return
00362         *    Content language
00363         *
00364         *  @remarks
00365         *    To access this information, Parse() has to be called first
00366         */
00367         inline String GetContentLanguage() const;
00368 
00369         /**
00370         *  @brief
00371         *    Get content type
00372         *
00373         *  @return
00374         *    Content type
00375         *
00376         *  @remarks
00377         *    To access this information, Parse() has to be called first
00378         */
00379         inline String GetContentType() const;
00380 
00381         /**
00382         *  @brief
00383         *    Get ETag
00384         *
00385         *  @return
00386         *    ETag for content
00387         *
00388         *  @remarks
00389         *    To access this information, Parse() has to be called first
00390         */
00391         inline String GetETag() const;
00392 
00393         /**
00394         *  @brief
00395         *    Check if partial data is returned
00396         *
00397         *  @return
00398         *    'true' if partial data is returned, else 'false'
00399         *
00400         *  @remarks
00401         *    To access this information, Parse() has to be called first
00402         */
00403         inline bool IsPartial() const;
00404 
00405         /**
00406         *  @brief
00407         *    Get start of range
00408         *
00409         *  @return
00410         *    Byte position
00411         *
00412         *  @remarks
00413         *    To access this information, Parse() has to be called first
00414         */
00415         inline uint32 GetRangeMin() const;
00416 
00417         /**
00418         *  @brief
00419         *    Get end of range
00420         *
00421         *  @return
00422         *    Byte position
00423         *
00424         *  @remarks
00425         *    To access this information, Parse() has to be called first
00426         */
00427         inline uint32 GetRangeMax() const;
00428 
00429         /**
00430         *  @brief
00431         *    Get total size
00432         *
00433         *  @return
00434         *    Size
00435         *
00436         *  @remarks
00437         *    To access this information, Parse() has to be called first
00438         */
00439         inline uint32 GetRangeTotal() const;
00440 
00441 
00442     //[-------------------------------------------------------]
00443     //[ Protected data                                        ]
00444     //[-------------------------------------------------------]
00445     protected:  
00446         Array<String>       m_lstEntries;           /**< Header entries */
00447         EHttpProtocol       m_nProtocol;            /**< HTTP protocol version */
00448         EHttpMessageType    m_nMessageType;         /**< Message type (request or response) */
00449         EHttpRequest        m_nRequest;             /**< Request type */
00450         String              m_sRequestUrl;          /**< Request URL */
00451         EHttpConnection     m_nConnection;          /**< Connection type (Close or KeepAlive) */
00452         EHttpStatus         m_nStatusCode;          /**< Status code */
00453         String              m_sStatusString;        /**< Status string */
00454         String              m_sLocation;            /**< Location */
00455         String              m_sDate;                /**< Date */
00456         String              m_sServer;              /**< Server signature */
00457         String              m_sUserAgent;           /**< Client signature */
00458         EHttpAuth           m_nAuthType;            /**< Authentication type */
00459         String              m_sAuthRealm;           /**< Authentication realm */
00460         String              m_sAuthorization;       /**< Authorization string */
00461         String              m_sTransferEncoding;    /**< Transfer encoding */
00462         uint32              m_nContentLength;       /**< Content size */
00463         String              m_sContentLanguage;     /**< Content language */
00464         String              m_sContentType;         /**< Content type (MIME type) */
00465         String              m_sETag;                /**< ETag (identifier for content) */
00466         bool                m_bPartial;             /**< Partial download? */
00467         uint32              m_nRangeMin;            /**< Start of range (for partial content) */
00468         uint32              m_nRangeMax;            /**< End of range   (for partial content) */
00469         uint32              m_nRangeTotal;          /**< Total size     (for partial content) */
00470     
00471 
00472 };
00473 
00474 
00475 //[-------------------------------------------------------]
00476 //[ Namespace                                             ]
00477 //[-------------------------------------------------------]
00478 } // PLCore
00479 
00480 
00481 //[-------------------------------------------------------]
00482 //[ Implementation                                        ]
00483 //[-------------------------------------------------------]
00484 #include "PLCore/Network/Http/HttpHeader.inl"
00485 
00486 
00487 #endif // __PLCORE_HTTPHEADER_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:56
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported