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
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 #ifndef _PHTTP
00227 #define _PHTTP
00228
00229 #ifdef P_USE_PRAGMA
00230 #pragma interface
00231 #endif
00232
00233 #include <ptclib/inetprot.h>
00234 #include <ptclib/mime.h>
00235 #include <ptclib/url.h>
00236 #include <ptclib/html.h>
00237 #include <ptlib/ipsock.h>
00238
00239
00241
00242
00243 class PHTTPResource;
00244
00249 class PHTTPSpace : public PContainer
00250 {
00251 PCONTAINERINFO(PHTTPSpace, PContainer)
00252 public:
00254 PHTTPSpace();
00255
00256
00257
00258 enum AddOptions {
00260 ErrorOnExist,
00262 Overwrite
00263 };
00264
00265
00277 BOOL AddResource(
00278 PHTTPResource * resource,
00279 AddOptions overwrite = ErrorOnExist
00281 );
00282
00290 BOOL DelResource(
00291 const PURL & url
00292 );
00293
00299 PHTTPResource * FindResource(
00300 const PURL & url
00301 );
00302
00305 void StartRead() const
00306 { mutex->StartRead(); }
00307
00310 void EndRead() const
00311 { mutex->EndRead(); }
00312
00315 void StartWrite() const
00316 { mutex->StartWrite(); }
00317
00320 void EndWrite() const
00321 { mutex->EndWrite(); }
00322
00323
00324 protected:
00325 PReadWriteMutex * mutex;
00326
00327 class Node;
00328 PSORTED_LIST(ChildList, Node);
00329 class Node : public PString
00330 {
00331 PCLASSINFO(Node, PString)
00332 public:
00333 Node(const PString & name, Node * parentNode);
00334 ~Node();
00335
00336 Node * parent;
00337 ChildList children;
00338 PHTTPResource * resource;
00339 } * root;
00340
00341 private:
00342 BOOL SetSize(PINDEX) { return FALSE; }
00343 };
00344
00345 #ifdef _WIN32_WCE
00346 #undef TRACE
00347 #endif
00348
00350
00351
00355 class PHTTP : public PInternetProtocol
00356 {
00357 PCLASSINFO(PHTTP, PInternetProtocol)
00358
00359 public:
00360
00361 enum Commands {
00362
00363 GET, HEAD, POST,
00364
00365 PUT, DELETE, TRACE, OPTIONS,
00366
00367 CONNECT,
00368 NumCommands
00369 };
00370
00371 enum StatusCode {
00372 Continue = 100,
00373 SwitchingProtocols,
00374 RequestOK = 200,
00375 Created,
00376 Accepted,
00377 NonAuthoritativeInformation,
00378 NoContent,
00379 ResetContent,
00380 PartialContent,
00381 MultipleChoices = 300,
00382 MovedPermanently,
00383 MovedTemporarily,
00384 SeeOther,
00385 NotModified,
00386 UseProxy,
00387 BadRequest = 400,
00388 UnAuthorised,
00389 PaymentRequired,
00390 Forbidden,
00391 NotFound,
00392 MethodNotAllowed,
00393 NoneAcceptable,
00394 ProxyAuthenticationRequired,
00395 RequestTimeout,
00396 Conflict,
00397 Gone,
00398 LengthRequired,
00399 UnlessTrue,
00400 InternalServerError = 500,
00401 NotImplemented,
00402 BadGateway,
00403 ServiceUnavailable,
00404 GatewayTimeout
00405 };
00406
00407
00408 static const char * const AllowTag;
00409 static const char * const AuthorizationTag;
00410 static const char * const ContentEncodingTag;
00411 static const char * const ContentLengthTag;
00412 static const char * const ContentTypeTag;
00413 static const char * const DateTag;
00414 static const char * const ExpiresTag;
00415 static const char * const FromTag;
00416 static const char * const IfModifiedSinceTag;
00417 static const char * const LastModifiedTag;
00418 static const char * const LocationTag;
00419 static const char * const PragmaTag;
00420 static const char * const PragmaNoCacheTag;
00421 static const char * const RefererTag;
00422 static const char * const ServerTag;
00423 static const char * const UserAgentTag;
00424 static const char * const WWWAuthenticateTag;
00425 static const char * const MIMEVersionTag;
00426 static const char * const ConnectionTag;
00427 static const char * const KeepAliveTag;
00428 static const char * const TransferEncodingTag;
00429 static const char * const ChunkedTag;
00430 static const char * const ProxyConnectionTag;
00431 static const char * const ProxyAuthorizationTag;
00432 static const char * const ProxyAuthenticateTag;
00433 static const char * const ForwardedTag;
00434 static const char * const SetCookieTag;
00435 static const char * const CookieTag;
00436
00437 protected:
00440 PHTTP();
00441
00453 virtual PINDEX ParseResponse(
00454 const PString & line
00455 );
00456 };
00457
00458
00460
00461
00482 class PHTTPClient : public PHTTP
00483 {
00484 PCLASSINFO(PHTTPClient, PHTTP)
00485
00486 public:
00488 PHTTPClient();
00489 PHTTPClient(
00490 const PString & userAgentName
00491 );
00492
00493
00494
00502 int ExecuteCommand(
00503 Commands cmd,
00504 const PURL & url,
00505 PMIMEInfo & outMIME,
00506 const PString & dataBody,
00507 PMIMEInfo & replyMime,
00508 BOOL persist = TRUE
00509 );
00510 int ExecuteCommand(
00511 const PString & cmdName,
00512 const PURL & url,
00513 PMIMEInfo & outMIME,
00514 const PString & dataBody,
00515 PMIMEInfo & replyMime,
00516 BOOL persist = TRUE
00517 );
00518
00520 BOOL WriteCommand(
00521 Commands cmd,
00522 const PString & url,
00523 PMIMEInfo & outMIME,
00524 const PString & dataBody
00525 );
00526 BOOL WriteCommand(
00527 const PString & cmdName,
00528 const PString & url,
00529 PMIMEInfo & outMIME,
00530 const PString & dataBody
00531 );
00532
00534 BOOL ReadResponse(
00535 PMIMEInfo & replyMIME
00536 );
00537
00539 BOOL ReadContentBody(
00540 PMIMEInfo & replyMIME,
00541 PBYTEArray & body
00542 );
00543 BOOL ReadContentBody(
00544 PMIMEInfo & replyMIME,
00545 PString & body
00546 );
00547
00548
00554 BOOL GetTextDocument(
00555 const PURL & url,
00556 PString & document,
00557 BOOL persist = TRUE
00558 );
00559
00565 BOOL GetDocument(
00566 const PURL & url,
00567 PMIMEInfo & outMIME,
00568 PMIMEInfo & replyMIME,
00569 BOOL persist = TRUE
00570 );
00571
00577 BOOL GetHeader(
00578 const PURL & url,
00579 PMIMEInfo & outMIME,
00580 PMIMEInfo & replyMIME,
00581 BOOL persist = TRUE
00582 );
00583
00584
00590 BOOL PostData(
00591 const PURL & url,
00592 PMIMEInfo & outMIME,
00593 const PString & data,
00594 PMIMEInfo & replyMIME,
00595 BOOL persist = TRUE
00596 );
00597
00603 BOOL PostData(
00604 const PURL & url,
00605 PMIMEInfo & outMIME,
00606 const PString & data,
00607 PMIMEInfo & replyMIME,
00608 PString & replyBody,
00609 BOOL persist = TRUE
00610 );
00611
00612 protected:
00613 BOOL AssureConnect(const PURL & url, PMIMEInfo & outMIME);
00614 BOOL InternalReadContentBody(
00615 PMIMEInfo & replyMIME,
00616 PAbstractArray & body
00617 );
00618
00619 PString userAgentName;
00620 };
00621
00622
00624
00625
00630 class PMultipartFormInfo : public PObject
00631 {
00632 PCLASSINFO(PMultipartFormInfo, PObject);
00633 public:
00634 PMIMEInfo mime;
00635 PString body;
00636 };
00637
00638 PARRAY(PMultipartFormInfoArray, PMultipartFormInfo);
00639
00641
00642
00643 class PHTTPServer;
00644
00649 class PHTTPConnectionInfo : public PObject
00650 {
00651 PCLASSINFO(PHTTPConnectionInfo, PObject)
00652 public:
00653 PHTTPConnectionInfo();
00654
00655 PHTTP::Commands GetCommandCode() const { return commandCode; }
00656 const PString & GetCommandName() const { return commandName; }
00657
00658 const PURL & GetURL() const { return url; }
00659
00660 const PMIMEInfo & GetMIME() const { return mimeInfo; }
00661 void SetMIME(const PString & tag, const PString & value);
00662
00663 BOOL IsCompatible(int major, int minor) const;
00664
00665 BOOL IsPersistant() const { return isPersistant; }
00666 BOOL WasPersistant() const { return wasPersistant; }
00667 BOOL IsProxyConnection() const { return isProxyConnection; }
00668 int GetMajorVersion() const { return majorVersion; }
00669 int GetMinorVersion() const { return minorVersion; }
00670
00671 long GetEntityBodyLength() const { return entityBodyLength; }
00672
00675 PTimeInterval GetPersistenceTimeout() const { return persistenceTimeout; }
00676
00679 void SetPersistenceTimeout(const PTimeInterval & t) { persistenceTimeout = t; }
00680
00684 unsigned GetPersistenceMaximumTransations() const { return persistenceMaximum; }
00685
00689 void SetPersistenceMaximumTransations(unsigned m) { persistenceMaximum = m; }
00690
00691 const PMultipartFormInfoArray & GetMultipartFormInfo() const
00692 { return multipartFormInfoArray; }
00693
00694 void ResetMultipartFormInfo()
00695 { multipartFormInfoArray.RemoveAll(); }
00696
00697 PString GetEntityBody() const { return entityBody; }
00698
00699 protected:
00700 BOOL Initialise(PHTTPServer & server, PString & args);
00701 void DecodeMultipartFormInfo(const PString & type, const PString & entityBody);
00702
00703 PHTTP::Commands commandCode;
00704 PString commandName;
00705 PURL url;
00706 PMIMEInfo mimeInfo;
00707 BOOL isPersistant;
00708 BOOL wasPersistant;
00709 BOOL isProxyConnection;
00710 int majorVersion;
00711 int minorVersion;
00712 PString entityBody;
00713 long entityBodyLength;
00714 PTimeInterval persistenceTimeout;
00715 unsigned persistenceMaximum;
00716 PMultipartFormInfoArray multipartFormInfoArray;
00717
00718 friend class PHTTPServer;
00719 };
00720
00721
00723
00724
00737 class PHTTPServer : public PHTTP
00738 {
00739 PCLASSINFO(PHTTPServer, PHTTP)
00740
00741 public:
00749 PHTTPServer();
00750 PHTTPServer(
00751 const PHTTPSpace & urlSpace
00752 );
00753
00754
00755
00761 virtual PString GetServerName() const;
00762
00768 PHTTPSpace & GetURLSpace() { return urlSpace; }
00769
00771 void SetURLSpace(
00772 const PHTTPSpace & space
00773 );
00774
00775
00785 virtual BOOL ProcessCommand();
00786
00798 virtual BOOL OnGET(
00799 const PURL & url,
00800 const PMIMEInfo & info,
00801 const PHTTPConnectionInfo & conInfo
00802 );
00803
00804
00805
00817 virtual BOOL OnHEAD(
00818 const PURL & url,
00819 const PMIMEInfo & info,
00820 const PHTTPConnectionInfo & conInfo
00821 );
00822
00834 virtual BOOL OnPOST(
00835 const PURL & url,
00836 const PMIMEInfo & info,
00837 const PStringToString & data,
00838 const PHTTPConnectionInfo & conInfo
00839 );
00840
00853 virtual BOOL OnProxy(
00854 const PHTTPConnectionInfo & conInfo
00855 );
00856
00857
00864 virtual PString ReadEntityBody();
00865
00871 virtual BOOL OnUnknown(
00872 const PCaselessString & command,
00873 const PHTTPConnectionInfo & connectInfo
00874 );
00875
00894 BOOL StartResponse(
00895 StatusCode code,
00896 PMIMEInfo & headers,
00897 long bodySize
00898 );
00899
00909 virtual BOOL OnError(
00910 StatusCode code,
00911 const PCaselessString & extra,
00912 const PHTTPConnectionInfo & connectInfo
00913 );
00914
00917 void SetDefaultMIMEInfo(
00918 PMIMEInfo & info,
00919 const PHTTPConnectionInfo & connectInfo
00920 );
00921
00924 PHTTPConnectionInfo & GetConnectionInfo() { return connectInfo; }
00925
00926 protected:
00927 void Construct();
00928
00929 PHTTPSpace urlSpace;
00930 PHTTPConnectionInfo connectInfo;
00931 unsigned transactionCount;
00932 PTimeInterval nextTimeout;
00933 };
00934
00935
00937
00938
00943 class PHTTPRequest : public PObject
00944 {
00945 PCLASSINFO(PHTTPRequest, PObject)
00946
00947 public:
00948 PHTTPRequest(
00949 const PURL & url,
00950 const PMIMEInfo & inMIME,
00951 const PMultipartFormInfoArray & multipartFormInfo,
00952 PHTTPServer & server
00953 );
00954
00955 PHTTPServer & server;
00956 const PURL & url;
00957 const PMIMEInfo & inMIME;
00958 const PMultipartFormInfoArray & multipartFormInfo;
00959 PHTTP::StatusCode code;
00960 PMIMEInfo outMIME;
00961 PString entityBody;
00962 PINDEX contentSize;
00963 PIPSocket::Address origin;
00964 PIPSocket::Address localAddr;
00965 WORD localPort;
00966 };
00967
00968
00970
00971
00975 class PHTTPAuthority : public PObject
00976 {
00977 PCLASSINFO(PHTTPAuthority, PObject)
00978
00979 public:
00980
00987 virtual PString GetRealm(
00988 const PHTTPRequest & request
00989 ) const = 0;
00990
00997 virtual BOOL Validate(
00998 const PHTTPRequest & request,
00999 const PString & authInfo
01000 ) const = 0;
01001
01011 virtual BOOL IsActive() const;
01012
01013 protected:
01014 static void DecodeBasicAuthority(
01015 const PString & authInfo,
01016 PString & username,
01017 PString & password
01018 );
01019 };
01020
01021
01023
01024
01028 class PHTTPSimpleAuth : public PHTTPAuthority
01029 {
01030 PCLASSINFO(PHTTPSimpleAuth, PHTTPAuthority)
01031
01032 public:
01033 PHTTPSimpleAuth(
01034 const PString & realm,
01035 const PString & username,
01036 const PString & password
01037 );
01038
01039
01040
01041
01049 virtual PObject * Clone() const;
01050
01051
01052
01059 virtual PString GetRealm(
01060 const PHTTPRequest & request
01061 ) const;
01062
01069 virtual BOOL Validate(
01070 const PHTTPRequest & request,
01071 const PString & authInfo
01072 ) const;
01073
01083 virtual BOOL IsActive() const;
01084
01090 const PString & GetUserName() const { return username; }
01091
01097 const PString & GetPassword() const { return password; }
01098
01099
01100 protected:
01101 PString realm;
01102 PString username;
01103 PString password;
01104 };
01105
01106
01108
01109
01113 class PHTTPMultiSimpAuth : public PHTTPAuthority
01114 {
01115 PCLASSINFO(PHTTPMultiSimpAuth, PHTTPAuthority)
01116
01117 public:
01118 PHTTPMultiSimpAuth(
01119 const PString & realm
01120 );
01121 PHTTPMultiSimpAuth(
01122 const PString & realm,
01123 const PStringToString & userList
01124 );
01125
01126
01127
01128
01136 virtual PObject * Clone() const;
01137
01138
01139
01146 virtual PString GetRealm(
01147 const PHTTPRequest & request
01148 ) const;
01149
01156 virtual BOOL Validate(
01157 const PHTTPRequest & request,
01158 const PString & authInfo
01159 ) const;
01160
01170 virtual BOOL IsActive() const;
01171
01177 void AddUser(
01178 const PString & username,
01179 const PString & password
01180 );
01181
01182
01183 protected:
01184 PString realm;
01185 PStringToString users;
01186 };
01187
01188
01190
01191
01195 class PHTTPResource : public PObject
01196 {
01197 PCLASSINFO(PHTTPResource, PObject)
01198
01199 protected:
01200 PHTTPResource(
01201 const PURL & url
01202 );
01203 PHTTPResource(
01204 const PURL & url,
01205 const PHTTPAuthority & auth
01206 );
01207 PHTTPResource(
01208 const PURL & url,
01209 const PString & contentType
01210 );
01211 PHTTPResource(
01212 const PURL & url,
01213 const PString & contentType,
01214 const PHTTPAuthority & auth
01215 );
01216
01217
01218
01219 public:
01220 virtual ~PHTTPResource();
01221
01222
01223
01224
01230 const PURL & GetURL() const { return baseURL; }
01231
01237 const PString & GetContentType() const { return contentType; }
01238
01245 PHTTPAuthority * GetAuthority() const { return authority; }
01246
01249 void SetAuthority(
01250 const PHTTPAuthority & auth
01251 );
01252
01255 void ClearAuthority();
01256
01263 DWORD GetHitCount() const { return hitCount; }
01264
01265 void ClearHitCount() { hitCount = 0; }
01266
01267
01268
01280 virtual BOOL OnGET(
01281 PHTTPServer & server,
01282 const PURL & url,
01283 const PMIMEInfo & info,
01284 const PHTTPConnectionInfo & conInfo
01285 );
01286
01296 virtual BOOL OnGETData(
01297 PHTTPServer & server,
01298 const PURL & url,
01299 const PHTTPConnectionInfo & connectInfo,
01300 PHTTPRequest & request
01301 );
01302
01314 virtual BOOL OnHEAD(
01315 PHTTPServer & server,
01316 const PURL & url,
01317 const PMIMEInfo & info,
01318 const PHTTPConnectionInfo & conInfo
01319 );
01320
01332 virtual BOOL OnPOST(
01333 PHTTPServer & server,
01334 const PURL & url,
01335 const PMIMEInfo & info,
01336 const PStringToString & data,
01337 const PHTTPConnectionInfo & conInfo
01338 );
01339
01349 virtual BOOL OnPOSTData(
01350 PHTTPRequest & request,
01351 const PStringToString & data
01352 );
01353
01360 virtual BOOL IsModifiedSince(
01361 const PTime & when
01362 );
01363
01369 virtual BOOL GetExpirationDate(
01370 PTime & when
01371 );
01372
01380 virtual PHTTPRequest * CreateRequest(
01381 const PURL & url,
01382 const PMIMEInfo & inMIME,
01383 const PMultipartFormInfoArray & multipartFormInfo,
01384 PHTTPServer & socket
01385 );
01386
01394 virtual BOOL LoadHeaders(
01395 PHTTPRequest & request
01396 ) = 0;
01397
01403 virtual void SendData(
01404 PHTTPRequest & request
01405 );
01406
01415 virtual BOOL LoadData(
01416 PHTTPRequest & request,
01417 PCharArray & data
01418 );
01419
01428 virtual PString LoadText(
01429 PHTTPRequest & request
01430 );
01431
01438 virtual void OnLoadedText(
01439 PHTTPRequest & request,
01440 PString & text
01441 );
01442
01451 virtual BOOL Post(
01452 PHTTPRequest & request,
01453 const PStringToString & data,
01454 PHTML & replyMessage
01455 );
01456
01457
01458 protected:
01461 virtual BOOL CheckAuthority(
01462 PHTTPServer & server,
01463 const PHTTPRequest & request,
01464 const PHTTPConnectionInfo & conInfo
01465 );
01466 static BOOL CheckAuthority(
01467 PHTTPAuthority & authority,
01468 PHTTPServer & server,
01469 const PHTTPRequest & request,
01470 const PHTTPConnectionInfo & connectInfo
01471 );
01472
01473
01475 virtual BOOL OnGETOrHEAD(
01476 PHTTPServer & server,
01477 const PURL & url,
01478 const PMIMEInfo & info,
01479 const PHTTPConnectionInfo & conInfo,
01480 BOOL IsGet
01481 );
01482
01484 PURL baseURL;
01486 PString contentType;
01488 PHTTPAuthority * authority;
01490 volatile DWORD hitCount;
01491 };
01492
01493
01495
01496
01501 class PHTTPString : public PHTTPResource
01502 {
01503 PCLASSINFO(PHTTPString, PHTTPResource)
01504
01505 public:
01509 PHTTPString(
01510 const PURL & url
01511 );
01512 PHTTPString(
01513 const PURL & url,
01514 const PHTTPAuthority & auth
01515 );
01516 PHTTPString(
01517 const PURL & url,
01518 const PString & str
01519 );
01520 PHTTPString(
01521 const PURL & url,
01522 const PString & str,
01523 const PString & contentType
01524 );
01525 PHTTPString(
01526 const PURL & url,
01527 const PString & str,
01528 const PHTTPAuthority & auth
01529 );
01530 PHTTPString(
01531 const PURL & url,
01532 const PString & str,
01533 const PString & contentType,
01534 const PHTTPAuthority & auth
01535 );
01536
01537
01538
01546 virtual BOOL LoadHeaders(
01547 PHTTPRequest & request
01548 );
01549
01558 virtual PString LoadText(
01559 PHTTPRequest & request
01560 );
01561
01562
01568 const PString & GetString() { return string; }
01569
01572 void SetString(
01573 const PString & str
01574 ) { string = str; }
01575
01576
01577 protected:
01578 PString string;
01579 };
01580
01581
01583
01584
01590 class PHTTPFile : public PHTTPResource
01591 {
01592 PCLASSINFO(PHTTPFile, PHTTPResource)
01593
01594 public:
01601 PHTTPFile(
01602 const PString & filename
01603 );
01604 PHTTPFile(
01605 const PString & filename,
01606 const PHTTPAuthority & auth
01607 );
01608 PHTTPFile(
01609 const PURL & url,
01610 const PFilePath & file
01611 );
01612 PHTTPFile(
01613 const PURL & url,
01614 const PFilePath & file,
01615 const PString & contentType
01616 );
01617 PHTTPFile(
01618 const PURL & url,
01619 const PFilePath & file,
01620 const PHTTPAuthority & auth
01621 );
01622 PHTTPFile(
01623 const PURL & url,
01624 const PFilePath & file,
01625 const PString & contentType,
01626 const PHTTPAuthority & auth
01627 );
01628
01629
01630
01636 virtual PHTTPRequest * CreateRequest(
01637 const PURL & url,
01638 const PMIMEInfo & inMIME,
01639 const PMultipartFormInfoArray & multipartFormInfo,
01640 PHTTPServer & socket
01641 );
01642
01650 virtual BOOL LoadHeaders(
01651 PHTTPRequest & request
01652 );
01653
01659 virtual BOOL LoadData(
01660 PHTTPRequest & request,
01661 PCharArray & data
01662 );
01663
01672 virtual PString LoadText(
01673 PHTTPRequest & request
01674 );
01675
01676
01677 protected:
01678 PHTTPFile(
01679 const PURL & url,
01680 int dummy
01681 );
01682
01683
01684
01685 PFilePath filePath;
01686 };
01687
01688
01689 class PHTTPFileRequest : public PHTTPRequest
01690 {
01691 PCLASSINFO(PHTTPFileRequest, PHTTPRequest)
01692 public:
01693 PHTTPFileRequest(
01694 const PURL & url,
01695 const PMIMEInfo & inMIME,
01696 const PMultipartFormInfoArray & multipartFormInfo,
01697 PHTTPServer & server
01698 );
01699
01700 PFile file;
01701 };
01702
01703
01705
01706
01715 class PHTTPTailFile : public PHTTPFile
01716 {
01717 PCLASSINFO(PHTTPTailFile, PHTTPFile)
01718
01719 public:
01726 PHTTPTailFile(
01727 const PString & filename
01728 );
01729 PHTTPTailFile(
01730 const PString & filename,
01731 const PHTTPAuthority & auth
01732 );
01733 PHTTPTailFile(
01734 const PURL & url,
01735 const PFilePath & file
01736 );
01737 PHTTPTailFile(
01738 const PURL & url,
01739 const PFilePath & file,
01740 const PString & contentType
01741 );
01742 PHTTPTailFile(
01743 const PURL & url,
01744 const PFilePath & file,
01745 const PHTTPAuthority & auth
01746 );
01747 PHTTPTailFile(
01748 const PURL & url,
01749 const PFilePath & file,
01750 const PString & contentType,
01751 const PHTTPAuthority & auth
01752 );
01753
01754
01755
01763 virtual BOOL LoadHeaders(
01764 PHTTPRequest & request
01765 );
01766
01772 virtual BOOL LoadData(
01773 PHTTPRequest & request,
01774 PCharArray & data
01775 );
01776 };
01777
01778
01780
01781
01794 class PHTTPDirectory : public PHTTPFile
01795 {
01796 PCLASSINFO(PHTTPDirectory, PHTTPFile)
01797
01798 public:
01799 PHTTPDirectory(
01800 const PURL & url,
01801 const PDirectory & dir
01802 );
01803 PHTTPDirectory(
01804 const PURL & url,
01805 const PDirectory & dir,
01806 const PHTTPAuthority & auth
01807 );
01808
01809
01810
01811
01817 virtual PHTTPRequest * CreateRequest(
01818 const PURL & url,
01819 const PMIMEInfo & inMIME,
01820 const PMultipartFormInfoArray & multipartFormInfo,
01821 PHTTPServer & socket
01822 );
01823
01831 virtual BOOL LoadHeaders(
01832 PHTTPRequest & request
01833 );
01834
01843 virtual PString LoadText(
01844 PHTTPRequest & request
01845 );
01846
01855 void EnableAuthorisation(const PString & realm);
01856
01859 void AllowDirectories(BOOL enable = TRUE);
01860
01861 protected:
01862 BOOL CheckAuthority(
01863 PHTTPServer & server,
01864 const PHTTPRequest & request,
01865 const PHTTPConnectionInfo & conInfo
01866 );
01867
01868 BOOL FindAuthorisations(const PDirectory & dir, PString & realm, PStringToString & authorisations);
01869
01870 PDirectory basePath;
01871 PString authorisationRealm;
01872 BOOL allowDirectoryListing;
01873 };
01874
01875
01876 class PHTTPDirRequest : public PHTTPFileRequest
01877 {
01878 PCLASSINFO(PHTTPDirRequest, PHTTPFileRequest)
01879 public:
01880 PHTTPDirRequest(
01881 const PURL & url,
01882 const PMIMEInfo & inMIME,
01883 const PMultipartFormInfoArray & multipartFormInfo,
01884 PHTTPServer & server
01885 );
01886
01887 PString fakeIndex;
01888 PFilePath realPath;
01889 };
01890
01891
01892 #endif
01893
01894
01895