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
00227
00228
00229
00230
00231
00232 #ifndef _PHTTP
00233 #define _PHTTP
00234
00235 #ifdef P_USE_PRAGMA
00236 #pragma interface
00237 #endif
00238
00239 #include <ptclib/inetprot.h>
00240 #include <ptclib/mime.h>
00241 #include <ptclib/url.h>
00242 #include <ptlib/ipsock.h>
00243
00244
00245 #ifdef P_HTTPSVC
00246
00247 #include <ptclib/html.h>
00248
00250
00251
00252 class PHTTPResource;
00253
00258 class PHTTPSpace : public PContainer
00259 {
00260 PCONTAINERINFO(PHTTPSpace, PContainer)
00261 public:
00263 PHTTPSpace();
00264
00265
00266
00267 enum AddOptions {
00269 ErrorOnExist,
00271 Overwrite
00272 };
00273
00274
00286 BOOL AddResource(
00287 PHTTPResource * resource,
00288 AddOptions overwrite = ErrorOnExist
00290 );
00291
00299 BOOL DelResource(
00300 const PURL & url
00301 );
00302
00308 PHTTPResource * FindResource(
00309 const PURL & url
00310 );
00311
00314 void StartRead() const
00315 { mutex->StartRead(); }
00316
00319 void EndRead() const
00320 { mutex->EndRead(); }
00321
00324 void StartWrite() const
00325 { mutex->StartWrite(); }
00326
00329 void EndWrite() const
00330 { mutex->EndWrite(); }
00331
00332
00333 protected:
00334 PReadWriteMutex * mutex;
00335
00336 class Node;
00337 PSORTED_LIST(ChildList, Node);
00338 class Node : public PString
00339 {
00340 PCLASSINFO(Node, PString)
00341 public:
00342 Node(const PString & name, Node * parentNode);
00343 ~Node();
00344
00345 Node * parent;
00346 ChildList children;
00347 PHTTPResource * resource;
00348 } * root;
00349
00350 private:
00351 BOOL SetSize(PINDEX) { return FALSE; }
00352 };
00353
00354 #endif // P_HTTPSVC
00355
00356 #ifdef _WIN32_WCE
00357 #undef TRACE
00358 #endif
00359
00361
00362
00366 class PHTTP : public PInternetProtocol
00367 {
00368 PCLASSINFO(PHTTP, PInternetProtocol)
00369
00370 public:
00371
00372 enum Commands {
00373
00374 GET, HEAD, POST,
00375
00376 PUT, DELETE, TRACE, OPTIONS,
00377
00378 CONNECT,
00379 NumCommands
00380 };
00381
00382 enum StatusCode {
00383 Continue = 100,
00384 SwitchingProtocols,
00385 RequestOK = 200,
00386 Created,
00387 Accepted,
00388 NonAuthoritativeInformation,
00389 NoContent,
00390 ResetContent,
00391 PartialContent,
00392 MultipleChoices = 300,
00393 MovedPermanently,
00394 MovedTemporarily,
00395 SeeOther,
00396 NotModified,
00397 UseProxy,
00398 BadRequest = 400,
00399 UnAuthorised,
00400 PaymentRequired,
00401 Forbidden,
00402 NotFound,
00403 MethodNotAllowed,
00404 NoneAcceptable,
00405 ProxyAuthenticationRequired,
00406 RequestTimeout,
00407 Conflict,
00408 Gone,
00409 LengthRequired,
00410 UnlessTrue,
00411 InternalServerError = 500,
00412 NotImplemented,
00413 BadGateway,
00414 ServiceUnavailable,
00415 GatewayTimeout
00416 };
00417
00418
00419 static const char * const AllowTag;
00420 static const char * const AuthorizationTag;
00421 static const char * const ContentEncodingTag;
00422 static const char * const ContentLengthTag;
00423 static const char * const ContentTypeTag;
00424 static const char * const DateTag;
00425 static const char * const ExpiresTag;
00426 static const char * const FromTag;
00427 static const char * const IfModifiedSinceTag;
00428 static const char * const LastModifiedTag;
00429 static const char * const LocationTag;
00430 static const char * const PragmaTag;
00431 static const char * const PragmaNoCacheTag;
00432 static const char * const RefererTag;
00433 static const char * const ServerTag;
00434 static const char * const UserAgentTag;
00435 static const char * const WWWAuthenticateTag;
00436 static const char * const MIMEVersionTag;
00437 static const char * const ConnectionTag;
00438 static const char * const KeepAliveTag;
00439 static const char * const TransferEncodingTag;
00440 static const char * const ChunkedTag;
00441 static const char * const ProxyConnectionTag;
00442 static const char * const ProxyAuthorizationTag;
00443 static const char * const ProxyAuthenticateTag;
00444 static const char * const ForwardedTag;
00445 static const char * const SetCookieTag;
00446 static const char * const CookieTag;
00447
00448 protected:
00451 PHTTP();
00452
00464 virtual PINDEX ParseResponse(
00465 const PString & line
00466 );
00467 };
00468
00469
00471
00472
00493 class PHTTPClient : public PHTTP
00494 {
00495 PCLASSINFO(PHTTPClient, PHTTP)
00496
00497 public:
00499 PHTTPClient();
00500 PHTTPClient(
00501 const PString & userAgentName
00502 );
00503
00504
00505
00513 int ExecuteCommand(
00514 Commands cmd,
00515 const PURL & url,
00516 PMIMEInfo & outMIME,
00517 const PString & dataBody,
00518 PMIMEInfo & replyMime,
00519 BOOL persist = TRUE
00520 );
00521 int ExecuteCommand(
00522 const PString & cmdName,
00523 const PURL & url,
00524 PMIMEInfo & outMIME,
00525 const PString & dataBody,
00526 PMIMEInfo & replyMime,
00527 BOOL persist = TRUE
00528 );
00529
00531 BOOL WriteCommand(
00532 Commands cmd,
00533 const PString & url,
00534 PMIMEInfo & outMIME,
00535 const PString & dataBody
00536 );
00537 BOOL WriteCommand(
00538 const PString & cmdName,
00539 const PString & url,
00540 PMIMEInfo & outMIME,
00541 const PString & dataBody
00542 );
00543
00545 BOOL ReadResponse(
00546 PMIMEInfo & replyMIME
00547 );
00548
00550 BOOL ReadContentBody(
00551 PMIMEInfo & replyMIME,
00552 PBYTEArray & body
00553 );
00554 BOOL ReadContentBody(
00555 PMIMEInfo & replyMIME,
00556 PString & body
00557 );
00558
00559
00565 BOOL GetTextDocument(
00566 const PURL & url,
00567 PString & document,
00568 BOOL persist = TRUE
00569 );
00570
00576 BOOL GetDocument(
00577 const PURL & url,
00578 PMIMEInfo & outMIME,
00579 PMIMEInfo & replyMIME,
00580 BOOL persist = TRUE
00581 );
00582
00588 BOOL GetHeader(
00589 const PURL & url,
00590 PMIMEInfo & outMIME,
00591 PMIMEInfo & replyMIME,
00592 BOOL persist = TRUE
00593 );
00594
00595
00601 BOOL PostData(
00602 const PURL & url,
00603 PMIMEInfo & outMIME,
00604 const PString & data,
00605 PMIMEInfo & replyMIME,
00606 BOOL persist = TRUE
00607 );
00608
00614 BOOL PostData(
00615 const PURL & url,
00616 PMIMEInfo & outMIME,
00617 const PString & data,
00618 PMIMEInfo & replyMIME,
00619 PString & replyBody,
00620 BOOL persist = TRUE
00621 );
00622
00623 protected:
00624 BOOL AssureConnect(const PURL & url, PMIMEInfo & outMIME);
00625 BOOL InternalReadContentBody(
00626 PMIMEInfo & replyMIME,
00627 PAbstractArray & body
00628 );
00629
00630 PString userAgentName;
00631 };
00632
00633 #ifdef P_HTTPSVC
00634
00636
00637
00642 class PMultipartFormInfo : public PObject
00643 {
00644 PCLASSINFO(PMultipartFormInfo, PObject);
00645 public:
00646 PMIMEInfo mime;
00647 PString body;
00648 };
00649
00650 PARRAY(PMultipartFormInfoArray, PMultipartFormInfo);
00651
00653
00654
00655 class PHTTPServer;
00656
00661 class PHTTPConnectionInfo : public PObject
00662 {
00663 PCLASSINFO(PHTTPConnectionInfo, PObject)
00664 public:
00665 PHTTPConnectionInfo();
00666
00667 PHTTP::Commands GetCommandCode() const { return commandCode; }
00668 const PString & GetCommandName() const { return commandName; }
00669
00670 const PURL & GetURL() const { return url; }
00671
00672 const PMIMEInfo & GetMIME() const { return mimeInfo; }
00673 void SetMIME(const PString & tag, const PString & value);
00674
00675 BOOL IsCompatible(int major, int minor) const;
00676
00677 BOOL IsPersistant() const { return isPersistant; }
00678 BOOL WasPersistant() const { return wasPersistant; }
00679 BOOL IsProxyConnection() const { return isProxyConnection; }
00680 int GetMajorVersion() const { return majorVersion; }
00681 int GetMinorVersion() const { return minorVersion; }
00682
00683 long GetEntityBodyLength() const { return entityBodyLength; }
00684
00687 PTimeInterval GetPersistenceTimeout() const { return persistenceTimeout; }
00688
00691 void SetPersistenceTimeout(const PTimeInterval & t) { persistenceTimeout = t; }
00692
00696 unsigned GetPersistenceMaximumTransations() const { return persistenceMaximum; }
00697
00701 void SetPersistenceMaximumTransations(unsigned m) { persistenceMaximum = m; }
00702
00703 const PMultipartFormInfoArray & GetMultipartFormInfo() const
00704 { return multipartFormInfoArray; }
00705
00706 void ResetMultipartFormInfo()
00707 { multipartFormInfoArray.RemoveAll(); }
00708
00709 PString GetEntityBody() const { return entityBody; }
00710
00711 protected:
00712 BOOL Initialise(PHTTPServer & server, PString & args);
00713 void DecodeMultipartFormInfo(const PString & type, const PString & entityBody);
00714
00715 PHTTP::Commands commandCode;
00716 PString commandName;
00717 PURL url;
00718 PMIMEInfo mimeInfo;
00719 BOOL isPersistant;
00720 BOOL wasPersistant;
00721 BOOL isProxyConnection;
00722 int majorVersion;
00723 int minorVersion;
00724 PString entityBody;
00725 long entityBodyLength;
00726 PTimeInterval persistenceTimeout;
00727 unsigned persistenceMaximum;
00728 PMultipartFormInfoArray multipartFormInfoArray;
00729
00730 friend class PHTTPServer;
00731 };
00732
00733
00735
00736
00749 class PHTTPServer : public PHTTP
00750 {
00751 PCLASSINFO(PHTTPServer, PHTTP)
00752
00753 public:
00761 PHTTPServer();
00762 PHTTPServer(
00763 const PHTTPSpace & urlSpace
00764 );
00765
00766
00767
00773 virtual PString GetServerName() const;
00774
00780 PHTTPSpace & GetURLSpace() { return urlSpace; }
00781
00783 void SetURLSpace(
00784 const PHTTPSpace & space
00785 );
00786
00787
00797 virtual BOOL ProcessCommand();
00798
00810 virtual BOOL OnGET(
00811 const PURL & url,
00812 const PMIMEInfo & info,
00813 const PHTTPConnectionInfo & conInfo
00814 );
00815
00816
00817
00829 virtual BOOL OnHEAD(
00830 const PURL & url,
00831 const PMIMEInfo & info,
00832 const PHTTPConnectionInfo & conInfo
00833 );
00834
00846 virtual BOOL OnPOST(
00847 const PURL & url,
00848 const PMIMEInfo & info,
00849 const PStringToString & data,
00850 const PHTTPConnectionInfo & conInfo
00851 );
00852
00865 virtual BOOL OnProxy(
00866 const PHTTPConnectionInfo & conInfo
00867 );
00868
00869
00876 virtual PString ReadEntityBody();
00877
00883 virtual BOOL OnUnknown(
00884 const PCaselessString & command,
00885 const PHTTPConnectionInfo & connectInfo
00886 );
00887
00906 BOOL StartResponse(
00907 StatusCode code,
00908 PMIMEInfo & headers,
00909 long bodySize
00910 );
00911
00921 virtual BOOL OnError(
00922 StatusCode code,
00923 const PCaselessString & extra,
00924 const PHTTPConnectionInfo & connectInfo
00925 );
00926
00929 void SetDefaultMIMEInfo(
00930 PMIMEInfo & info,
00931 const PHTTPConnectionInfo & connectInfo
00932 );
00933
00936 PHTTPConnectionInfo & GetConnectionInfo() { return connectInfo; }
00937
00938 protected:
00939 void Construct();
00940
00941 PHTTPSpace urlSpace;
00942 PHTTPConnectionInfo connectInfo;
00943 unsigned transactionCount;
00944 PTimeInterval nextTimeout;
00945 };
00946
00947
00949
00950
00955 class PHTTPRequest : public PObject
00956 {
00957 PCLASSINFO(PHTTPRequest, PObject)
00958
00959 public:
00960 PHTTPRequest(
00961 const PURL & url,
00962 const PMIMEInfo & inMIME,
00963 const PMultipartFormInfoArray & multipartFormInfo,
00964 PHTTPServer & server
00965 );
00966
00967 PHTTPServer & server;
00968 const PURL & url;
00969 const PMIMEInfo & inMIME;
00970 const PMultipartFormInfoArray & multipartFormInfo;
00971 PHTTP::StatusCode code;
00972 PMIMEInfo outMIME;
00973 PString entityBody;
00974 PINDEX contentSize;
00975 PIPSocket::Address origin;
00976 PIPSocket::Address localAddr;
00977 WORD localPort;
00978 };
00979
00980
00982
00983
00987 class PHTTPAuthority : public PObject
00988 {
00989 PCLASSINFO(PHTTPAuthority, PObject)
00990
00991 public:
00992
00999 virtual PString GetRealm(
01000 const PHTTPRequest & request
01001 ) const = 0;
01002
01009 virtual BOOL Validate(
01010 const PHTTPRequest & request,
01011 const PString & authInfo
01012 ) const = 0;
01013
01023 virtual BOOL IsActive() const;
01024
01025 protected:
01026 static void DecodeBasicAuthority(
01027 const PString & authInfo,
01028 PString & username,
01029 PString & password
01030 );
01031 };
01032
01033
01035
01036
01040 class PHTTPSimpleAuth : public PHTTPAuthority
01041 {
01042 PCLASSINFO(PHTTPSimpleAuth, PHTTPAuthority)
01043
01044 public:
01045 PHTTPSimpleAuth(
01046 const PString & realm,
01047 const PString & username,
01048 const PString & password
01049 );
01050
01051
01052
01053
01061 virtual PObject * Clone() const;
01062
01063
01064
01071 virtual PString GetRealm(
01072 const PHTTPRequest & request
01073 ) const;
01074
01081 virtual BOOL Validate(
01082 const PHTTPRequest & request,
01083 const PString & authInfo
01084 ) const;
01085
01095 virtual BOOL IsActive() const;
01096
01102 const PString & GetUserName() const { return username; }
01103
01109 const PString & GetPassword() const { return password; }
01110
01111
01112 protected:
01113 PString realm;
01114 PString username;
01115 PString password;
01116 };
01117
01118
01120
01121
01125 class PHTTPMultiSimpAuth : public PHTTPAuthority
01126 {
01127 PCLASSINFO(PHTTPMultiSimpAuth, PHTTPAuthority)
01128
01129 public:
01130 PHTTPMultiSimpAuth(
01131 const PString & realm
01132 );
01133 PHTTPMultiSimpAuth(
01134 const PString & realm,
01135 const PStringToString & userList
01136 );
01137
01138
01139
01140
01148 virtual PObject * Clone() const;
01149
01150
01151
01158 virtual PString GetRealm(
01159 const PHTTPRequest & request
01160 ) const;
01161
01168 virtual BOOL Validate(
01169 const PHTTPRequest & request,
01170 const PString & authInfo
01171 ) const;
01172
01182 virtual BOOL IsActive() const;
01183
01189 void AddUser(
01190 const PString & username,
01191 const PString & password
01192 );
01193
01194
01195 protected:
01196 PString realm;
01197 PStringToString users;
01198 };
01199
01200
01202
01203
01207 class PHTTPResource : public PObject
01208 {
01209 PCLASSINFO(PHTTPResource, PObject)
01210
01211 protected:
01212 PHTTPResource(
01213 const PURL & url
01214 );
01215 PHTTPResource(
01216 const PURL & url,
01217 const PHTTPAuthority & auth
01218 );
01219 PHTTPResource(
01220 const PURL & url,
01221 const PString & contentType
01222 );
01223 PHTTPResource(
01224 const PURL & url,
01225 const PString & contentType,
01226 const PHTTPAuthority & auth
01227 );
01228
01229
01230
01231 public:
01232 virtual ~PHTTPResource();
01233
01234
01235
01236
01242 const PURL & GetURL() const { return baseURL; }
01243
01249 const PString & GetContentType() const { return contentType; }
01250
01257 PHTTPAuthority * GetAuthority() const { return authority; }
01258
01261 void SetAuthority(
01262 const PHTTPAuthority & auth
01263 );
01264
01267 void ClearAuthority();
01268
01275 DWORD GetHitCount() const { return hitCount; }
01276
01277 void ClearHitCount() { hitCount = 0; }
01278
01279
01280
01292 virtual BOOL OnGET(
01293 PHTTPServer & server,
01294 const PURL & url,
01295 const PMIMEInfo & info,
01296 const PHTTPConnectionInfo & conInfo
01297 );
01298
01308 virtual BOOL OnGETData(
01309 PHTTPServer & server,
01310 const PURL & url,
01311 const PHTTPConnectionInfo & connectInfo,
01312 PHTTPRequest & request
01313 );
01314
01326 virtual BOOL OnHEAD(
01327 PHTTPServer & server,
01328 const PURL & url,
01329 const PMIMEInfo & info,
01330 const PHTTPConnectionInfo & conInfo
01331 );
01332
01344 virtual BOOL OnPOST(
01345 PHTTPServer & server,
01346 const PURL & url,
01347 const PMIMEInfo & info,
01348 const PStringToString & data,
01349 const PHTTPConnectionInfo & conInfo
01350 );
01351
01361 virtual BOOL OnPOSTData(
01362 PHTTPRequest & request,
01363 const PStringToString & data
01364 );
01365
01372 virtual BOOL IsModifiedSince(
01373 const PTime & when
01374 );
01375
01381 virtual BOOL GetExpirationDate(
01382 PTime & when
01383 );
01384
01392 virtual PHTTPRequest * CreateRequest(
01393 const PURL & url,
01394 const PMIMEInfo & inMIME,
01395 const PMultipartFormInfoArray & multipartFormInfo,
01396 PHTTPServer & socket
01397 );
01398
01406 virtual BOOL LoadHeaders(
01407 PHTTPRequest & request
01408 ) = 0;
01409
01415 virtual void SendData(
01416 PHTTPRequest & request
01417 );
01418
01427 virtual BOOL LoadData(
01428 PHTTPRequest & request,
01429 PCharArray & data
01430 );
01431
01440 virtual PString LoadText(
01441 PHTTPRequest & request
01442 );
01443
01450 virtual void OnLoadedText(
01451 PHTTPRequest & request,
01452 PString & text
01453 );
01454
01463 virtual BOOL Post(
01464 PHTTPRequest & request,
01465 const PStringToString & data,
01466 PHTML & replyMessage
01467 );
01468
01469
01470 protected:
01473 virtual BOOL CheckAuthority(
01474 PHTTPServer & server,
01475 const PHTTPRequest & request,
01476 const PHTTPConnectionInfo & conInfo
01477 );
01478 static BOOL CheckAuthority(
01479 PHTTPAuthority & authority,
01480 PHTTPServer & server,
01481 const PHTTPRequest & request,
01482 const PHTTPConnectionInfo & connectInfo
01483 );
01484
01485
01487 virtual BOOL OnGETOrHEAD(
01488 PHTTPServer & server,
01489 const PURL & url,
01490 const PMIMEInfo & info,
01491 const PHTTPConnectionInfo & conInfo,
01492 BOOL IsGet
01493 );
01494
01496 PURL baseURL;
01498 PString contentType;
01500 PHTTPAuthority * authority;
01502 volatile DWORD hitCount;
01503 };
01504
01505
01507
01508
01513 class PHTTPString : public PHTTPResource
01514 {
01515 PCLASSINFO(PHTTPString, PHTTPResource)
01516
01517 public:
01521 PHTTPString(
01522 const PURL & url
01523 );
01524 PHTTPString(
01525 const PURL & url,
01526 const PHTTPAuthority & auth
01527 );
01528 PHTTPString(
01529 const PURL & url,
01530 const PString & str
01531 );
01532 PHTTPString(
01533 const PURL & url,
01534 const PString & str,
01535 const PString & contentType
01536 );
01537 PHTTPString(
01538 const PURL & url,
01539 const PString & str,
01540 const PHTTPAuthority & auth
01541 );
01542 PHTTPString(
01543 const PURL & url,
01544 const PString & str,
01545 const PString & contentType,
01546 const PHTTPAuthority & auth
01547 );
01548
01549
01550
01558 virtual BOOL LoadHeaders(
01559 PHTTPRequest & request
01560 );
01561
01570 virtual PString LoadText(
01571 PHTTPRequest & request
01572 );
01573
01574
01580 const PString & GetString() { return string; }
01581
01584 void SetString(
01585 const PString & str
01586 ) { string = str; }
01587
01588
01589 protected:
01590 PString string;
01591 };
01592
01593
01595
01596
01602 class PHTTPFile : public PHTTPResource
01603 {
01604 PCLASSINFO(PHTTPFile, PHTTPResource)
01605
01606 public:
01613 PHTTPFile(
01614 const PString & filename
01615 );
01616 PHTTPFile(
01617 const PString & filename,
01618 const PHTTPAuthority & auth
01619 );
01620 PHTTPFile(
01621 const PURL & url,
01622 const PFilePath & file
01623 );
01624 PHTTPFile(
01625 const PURL & url,
01626 const PFilePath & file,
01627 const PString & contentType
01628 );
01629 PHTTPFile(
01630 const PURL & url,
01631 const PFilePath & file,
01632 const PHTTPAuthority & auth
01633 );
01634 PHTTPFile(
01635 const PURL & url,
01636 const PFilePath & file,
01637 const PString & contentType,
01638 const PHTTPAuthority & auth
01639 );
01640
01641
01642
01648 virtual PHTTPRequest * CreateRequest(
01649 const PURL & url,
01650 const PMIMEInfo & inMIME,
01651 const PMultipartFormInfoArray & multipartFormInfo,
01652 PHTTPServer & socket
01653 );
01654
01662 virtual BOOL LoadHeaders(
01663 PHTTPRequest & request
01664 );
01665
01671 virtual BOOL LoadData(
01672 PHTTPRequest & request,
01673 PCharArray & data
01674 );
01675
01684 virtual PString LoadText(
01685 PHTTPRequest & request
01686 );
01687
01688
01689 protected:
01690 PHTTPFile(
01691 const PURL & url,
01692 int dummy
01693 );
01694
01695
01696
01697 PFilePath filePath;
01698 };
01699
01700
01701 class PHTTPFileRequest : public PHTTPRequest
01702 {
01703 PCLASSINFO(PHTTPFileRequest, PHTTPRequest)
01704 public:
01705 PHTTPFileRequest(
01706 const PURL & url,
01707 const PMIMEInfo & inMIME,
01708 const PMultipartFormInfoArray & multipartFormInfo,
01709 PHTTPServer & server
01710 );
01711
01712 PFile file;
01713 };
01714
01715
01717
01718
01727 class PHTTPTailFile : public PHTTPFile
01728 {
01729 PCLASSINFO(PHTTPTailFile, PHTTPFile)
01730
01731 public:
01738 PHTTPTailFile(
01739 const PString & filename
01740 );
01741 PHTTPTailFile(
01742 const PString & filename,
01743 const PHTTPAuthority & auth
01744 );
01745 PHTTPTailFile(
01746 const PURL & url,
01747 const PFilePath & file
01748 );
01749 PHTTPTailFile(
01750 const PURL & url,
01751 const PFilePath & file,
01752 const PString & contentType
01753 );
01754 PHTTPTailFile(
01755 const PURL & url,
01756 const PFilePath & file,
01757 const PHTTPAuthority & auth
01758 );
01759 PHTTPTailFile(
01760 const PURL & url,
01761 const PFilePath & file,
01762 const PString & contentType,
01763 const PHTTPAuthority & auth
01764 );
01765
01766
01767
01775 virtual BOOL LoadHeaders(
01776 PHTTPRequest & request
01777 );
01778
01784 virtual BOOL LoadData(
01785 PHTTPRequest & request,
01786 PCharArray & data
01787 );
01788 };
01789
01790
01792
01793
01806 class PHTTPDirectory : public PHTTPFile
01807 {
01808 PCLASSINFO(PHTTPDirectory, PHTTPFile)
01809
01810 public:
01811 PHTTPDirectory(
01812 const PURL & url,
01813 const PDirectory & dir
01814 );
01815 PHTTPDirectory(
01816 const PURL & url,
01817 const PDirectory & dir,
01818 const PHTTPAuthority & auth
01819 );
01820
01821
01822
01823
01829 virtual PHTTPRequest * CreateRequest(
01830 const PURL & url,
01831 const PMIMEInfo & inMIME,
01832 const PMultipartFormInfoArray & multipartFormInfo,
01833 PHTTPServer & socket
01834 );
01835
01843 virtual BOOL LoadHeaders(
01844 PHTTPRequest & request
01845 );
01846
01855 virtual PString LoadText(
01856 PHTTPRequest & request
01857 );
01858
01867 void EnableAuthorisation(const PString & realm);
01868
01871 void AllowDirectories(BOOL enable = TRUE);
01872
01873 protected:
01874 BOOL CheckAuthority(
01875 PHTTPServer & server,
01876 const PHTTPRequest & request,
01877 const PHTTPConnectionInfo & conInfo
01878 );
01879
01880 BOOL FindAuthorisations(const PDirectory & dir, PString & realm, PStringToString & authorisations);
01881
01882 PDirectory basePath;
01883 PString authorisationRealm;
01884 BOOL allowDirectoryListing;
01885 };
01886
01887
01888 class PHTTPDirRequest : public PHTTPFileRequest
01889 {
01890 PCLASSINFO(PHTTPDirRequest, PHTTPFileRequest)
01891 public:
01892 PHTTPDirRequest(
01893 const PURL & url,
01894 const PMIMEInfo & inMIME,
01895 const PMultipartFormInfoArray & multipartFormInfo,
01896 PHTTPServer & server
01897 );
01898
01899 PString fakeIndex;
01900 PFilePath realPath;
01901 };
01902
01903 #endif // P_HTTPSVC
01904
01905 #endif
01906
01907
01908