00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef INC_MI32_HTTPMSG_H
00051 #define INC_MI32_HTTPMSG_H
00052
00053 #ifndef INC_MI32_MILIST_H
00054 #include <mi32/milist.h>
00055 #endif
00056
00057 #ifndef INC_MI32_MISTRING_H
00058 #include <mi32/mistring.h>
00059 #endif
00060
00061
00062 #ifdef MISYSTEMDLL
00063 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00064 #else
00065 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00066 #endif
00067
00068
00069 #ifndef GENERATING_DOXYGEN_OUTPUT
00070 class DATETIME;
00071 class FILEPATH;
00072 class STRUTF8;
00073 class XMLDOC;
00074 #endif
00075
00076
00087 class CLASSLIBEXPORT HTTPMESSAGE {
00088 public:
00089
00090 enum METHOD {
00091 METHOD_REPLY = 0,
00092 METHOD_OPTIONS = 1,
00093 METHOD_GET,
00094 METHOD_HEAD,
00095 METHOD_POST,
00096 METHOD_PUT,
00097 METHOD_DELETE,
00098 METHOD_TRACE,
00099 METHOD_CONNECT,
00100 METHOD_NUM_METHODS = 16
00101 };
00102
00109 enum STATUS {
00110 STATUS_EmptyMessage = 0,
00111
00112 STATUS_Continue = 100,
00113
00114 STATUS_OK = 200,
00115 STATUS_Created = 201,
00116 STATUS_Accepted = 202,
00117 STATUS_NonAuthoritativeInfo = 203,
00118 STATUS_NoContent = 204,
00119 STATUS_ResetContent = 205,
00120 STATUS_PartialContent = 206,
00121
00122 STATUS_MultipleChoices = 300,
00123 STATUS_MovedPermanently = 301,
00124 STATUS_Found = 302,
00125 STATUS_SeeOther = 303,
00126 STATUS_NotModified = 304,
00127 STATUS_UseProxy = 305,
00128
00129 STATUS_TemporaryRedirect = 307,
00130
00131 STATUS_BadRequest = 400,
00132 STATUS_Unauthorized = 401,
00133 STATUS_PaymentRequired = 402,
00134 STATUS_Forbidden = 403,
00135 STATUS_NotFound = 404,
00136 STATUS_MethodNotAllowed = 405,
00137 STATUS_NotAcceptable = 406,
00138 STATUS_ProxyAuthenticationRequired = 407,
00139 STATUS_RequestTimeOut = 408,
00140 STATUS_Conflict = 409,
00141 STATUS_Gone = 410,
00142 STATUS_LengthRequired = 411,
00143 STATUS_PreconditionFailed = 412,
00144 STATUS_RequestEntityTooLarge = 413,
00145 STATUS_RequestURITooLarge = 414,
00146 STATUS_UnsupportedMediaType = 415,
00147 STATUS_RequestedRangeNotSatisfiable = 416,
00148 STATUS_ExpectationFailed = 417,
00149
00150 STATUS_InternalServerError = 500,
00151 STATUS_NotImplemented = 501,
00152 STATUS_BadGateway = 502,
00153 STATUS_ServiceUnavailable = 503,
00154 STATUS_GatewayTimeOut = 504,
00155 STATUS_HTTPVersionNotSupported = 505
00156 };
00157
00159 static MISTRING GetStatusText (
00160 STATUS status
00161 );
00162
00164 HTTPMESSAGE ();
00165
00167 HTTPMESSAGE (
00168 const HTTPMESSAGE& rhs
00169 );
00170
00171 ~HTTPMESSAGE ();
00172
00174 HTTPMESSAGE& operator= (
00175 const HTTPMESSAGE& rhs
00176 );
00177
00181 void AddHeader (
00182 const STRUTF8& header
00183 );
00184
00187 ERRVALUE AppendToBody (
00188 const void* data,
00189 int numbytes
00190 );
00191
00193 ERRVALUE AppendToBody (
00194 const MISTRING& data
00195 );
00196
00202 void ClearDestFile ();
00203
00206 void CloseDestFile ();
00207
00214 UINT8* DetachData ();
00215
00219 void GenerateEscapedRequestURI (
00220 STRUTF8& uri
00221 ) const;
00222
00224 ERRVALUE GetContent (
00225 MISTRING& mistr
00226 ) const;
00227
00229 ERRVALUE GetContent (
00230 STRUTF8& mistr
00231 ) const;
00232
00245 ERRVALUE GetContent (
00246 XMLDOC& mistr
00247 ) const;
00248
00252 CHAR_ENCODING GetContentCharEncoding () const;
00253
00257 bool GetContentCharEncoding (
00258 STRUTF8& str
00259 ) const;
00260
00265 const char* GetContentType () const;
00266
00272 const UINT8* GetData (
00273 ) const;
00274
00275 #ifndef GENERATING_DOXYGEN_OUTPUT
00278 UINT8* GetData (
00279 );
00280 #endif
00281
00287 const FILEPATH& GetDestFile () const;
00288
00290 const STRUTF8& GetEscapedRequestURI () const;
00291
00293 const MILIST<STRUTF8>& GetExtraHeaders (
00294 ) const;
00295
00296
00297
00298
00299
00300 const char* GetHeaderString (
00301 const char* key
00302 ) const;
00303
00305 bool GetKeepAlive () const;
00306
00309 const DATETIME& GetMessageTime (
00310 ) const;
00311
00314 const STRUTF8& GetMultiPartBoundary () const;
00315
00317 int GetNumBytes (
00318 ) const;
00319
00325 int GetNumBytesExpected (
00326 ) const;
00327
00328 METHOD GetRequestMethod () const;
00329
00331 const STRUTF8& GetRequestURI (
00332 ) const;
00333
00335 STATUS GetStatusCode () const;
00336
00338 const STRUTF8& GetStatusMessage () const;
00339
00341 const DATETIME& GetTimeLastModified () const;
00342
00344 bool HasCharEncoding () const;
00345
00347 bool IsCachedResult () const;
00348
00353 bool IsHeadRequest () const;
00354
00356 bool IsDirectToFile () const;
00357
00360 ERRVALUE Reserve (
00361 int size
00362 );
00363
00365 void Reset ();
00366
00368 ERRVALUE Resize (
00369 int size
00370 );
00371
00373 void SetContentCharEncoding (
00374 CHAR_ENCODING encoding
00375 );
00376
00380 void SetContentCharEncoding (
00381 const char* encoding
00382 );
00383
00386 void SetContentType (
00387 const char* ContentType
00388 );
00389
00394 void SetDestFile (
00395 const FILEPATH& filepath
00396 );
00397
00399 void SetIsCachedResult (
00400 bool bCachedResult
00401 );
00402
00404 void SetKeepAlive (
00405 bool bKeepAlive = true
00406 );
00407
00412 void SetMessageTime (
00413 const DATETIME& dts
00414 );
00415
00417 void SetRequest (
00418 METHOD method,
00419 const STRUTF8& uri,
00420 bool bIsEscaped = false
00421 );
00422
00424 void SetStatusCode (
00425 STATUS status
00426 );
00427
00432 void SetStatusMessage (
00433 const char* msg
00434 );
00435
00438 void SetTimeLastModified (
00439 const DATETIME& dts
00440 );
00441
00442 private:
00443 #ifndef GENERATING_DOXYGEN_OUTPUT
00444 class PRIV;
00445 PRIV *m_priv;
00446 #endif // GENERATING_DOXYGEN_OUTPUT
00447 };
00448
00449 #undef CLASSLIBEXPORT
00450
00451 #endif // INC_MI32_HTTPMSG_H