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 #ifndef PTLIB_HTTP_H
00032 #define PTLIB_HTTP_H
00033
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037
00038 #if P_HTTP
00039
00040 #include <ptclib/inetprot.h>
00041 #include <ptclib/mime.h>
00042 #include <ptclib/url.h>
00043 #include <ptlib/ipsock.h>
00044
00045
00046 #include <ptclib/html.h>
00047
00049
00050
00051 class PHTTPResource;
00052
00057 class PHTTPSpace : public PContainer
00058 {
00059 PCONTAINERINFO(PHTTPSpace, PContainer)
00060 public:
00062 PHTTPSpace();
00063
00064
00065
00066 enum AddOptions {
00068 ErrorOnExist,
00070 Overwrite
00071 };
00072
00073
00085 PBoolean AddResource(
00086 PHTTPResource * resource,
00087 AddOptions overwrite = ErrorOnExist
00089 );
00090
00098 PBoolean DelResource(
00099 const PURL & url
00100 );
00101
00107 PHTTPResource * FindResource(
00108 const PURL & url
00109 );
00110
00113 void StartRead() const
00114 { mutex->StartRead(); }
00115
00118 void EndRead() const
00119 { mutex->EndRead(); }
00120
00123 void StartWrite() const
00124 { mutex->StartWrite(); }
00125
00128 void EndWrite() const
00129 { mutex->EndWrite(); }
00130
00131
00132 protected:
00133 PReadWriteMutex * mutex;
00134
00135 class Node;
00136 PSORTED_LIST(ChildList, Node);
00137 class Node : public PString
00138 {
00139 PCLASSINFO(Node, PString)
00140 public:
00141 Node(const PString & name, Node * parentNode);
00142 ~Node();
00143
00144 Node * parent;
00145 ChildList children;
00146 PHTTPResource * resource;
00147 } * root;
00148
00149 private:
00150 PBoolean SetSize(PINDEX) { return PFalse; }
00151 };
00152
00153 #ifdef _WIN32_WCE
00154 #undef TRACE
00155 #endif
00156
00158
00159
00163 class PHTTP : public PInternetProtocol
00164 {
00165 PCLASSINFO(PHTTP, PInternetProtocol)
00166
00167 public:
00168
00169 enum Commands {
00170
00171 GET, HEAD, POST,
00172
00173 PUT, DELETE, TRACE, OPTIONS,
00174
00175 CONNECT,
00176 NumCommands
00177 };
00178
00179 enum StatusCode {
00180 Continue = 100,
00181 SwitchingProtocols,
00182 RequestOK = 200,
00183 Created,
00184 Accepted,
00185 NonAuthoritativeInformation,
00186 NoContent,
00187 ResetContent,
00188 PartialContent,
00189 MultipleChoices = 300,
00190 MovedPermanently,
00191 MovedTemporarily,
00192 SeeOther,
00193 NotModified,
00194 UseProxy,
00195 BadRequest = 400,
00196 UnAuthorised,
00197 PaymentRequired,
00198 Forbidden,
00199 NotFound,
00200 MethodNotAllowed,
00201 NoneAcceptable,
00202 ProxyAuthenticationRequired,
00203 RequestTimeout,
00204 Conflict,
00205 Gone,
00206 LengthRequired,
00207 UnlessTrue,
00208 InternalServerError = 500,
00209 NotImplemented,
00210 BadGateway,
00211 ServiceUnavailable,
00212 GatewayTimeout
00213 };
00214
00215
00216 static const PString & AllowTag();
00217 static const PString & AuthorizationTag();
00218 static const PString & ContentEncodingTag();
00219 static const PString & ContentLengthTag();
00220 static const PString & ContentTypeTag();
00221 static const PString & DateTag();
00222 static const PString & ExpiresTag();
00223 static const PString & FromTag();
00224 static const PString & IfModifiedSinceTag();
00225 static const PString & LastModifiedTag();
00226 static const PString & LocationTag();
00227 static const PString & PragmaTag();
00228 static const PString & PragmaNoCacheTag();
00229 static const PString & RefererTag();
00230 static const PString & ServerTag();
00231 static const PString & UserAgentTag();
00232 static const PString & WWWAuthenticateTag();
00233 static const PString & MIMEVersionTag();
00234 static const PString & ConnectionTag();
00235 static const PString & KeepAliveTag();
00236 static const PString & TransferEncodingTag();
00237 static const PString & ChunkedTag();
00238 static const PString & ProxyConnectionTag();
00239 static const PString & ProxyAuthorizationTag();
00240 static const PString & ProxyAuthenticateTag();
00241 static const PString & ForwardedTag();
00242 static const PString & SetCookieTag();
00243 static const PString & CookieTag();
00244
00245 protected:
00248 PHTTP();
00249
00261 virtual PINDEX ParseResponse(
00262 const PString & line
00263 );
00264 };
00265
00266
00268
00269
00290 class PHTTPClient : public PHTTP
00291 {
00292 PCLASSINFO(PHTTPClient, PHTTP)
00293
00294 public:
00296 PHTTPClient();
00297 PHTTPClient(
00298 const PString & userAgentName
00299 );
00300
00301
00302
00310 int ExecuteCommand(
00311 Commands cmd,
00312 const PURL & url,
00313 PMIMEInfo & outMIME,
00314 const PString & dataBody,
00315 PMIMEInfo & replyMime,
00316 PBoolean persist = PTrue
00317 );
00318 int ExecuteCommand(
00319 const PString & cmdName,
00320 const PURL & url,
00321 PMIMEInfo & outMIME,
00322 const PString & dataBody,
00323 PMIMEInfo & replyMime,
00324 PBoolean persist = PTrue
00325 );
00326
00328 PBoolean WriteCommand(
00329 Commands cmd,
00330 const PString & url,
00331 PMIMEInfo & outMIME,
00332 const PString & dataBody
00333 );
00334 PBoolean WriteCommand(
00335 const PString & cmdName,
00336 const PString & url,
00337 PMIMEInfo & outMIME,
00338 const PString & dataBody
00339 );
00340
00342 PBoolean ReadResponse(
00343 PMIMEInfo & replyMIME
00344 );
00345
00347 PBoolean ReadContentBody(
00348 PMIMEInfo & replyMIME,
00349 PBYTEArray & body
00350 );
00351 PBoolean ReadContentBody(
00352 PMIMEInfo & replyMIME,
00353 PString & body
00354 );
00355
00356
00362 PBoolean GetTextDocument(
00363 const PURL & url,
00364 PString & document,
00365 PBoolean persist = PTrue
00366 );
00367
00373 PBoolean GetDocument(
00374 const PURL & url,
00375 PMIMEInfo & outMIME,
00376 PMIMEInfo & replyMIME,
00377 PBoolean persist = PTrue
00378 );
00379
00385 PBoolean GetHeader(
00386 const PURL & url,
00387 PMIMEInfo & outMIME,
00388 PMIMEInfo & replyMIME,
00389 PBoolean persist = PTrue
00390 );
00391
00392
00398 PBoolean PostData(
00399 const PURL & url,
00400 PMIMEInfo & outMIME,
00401 const PString & data,
00402 PMIMEInfo & replyMIME,
00403 PBoolean persist = PTrue
00404 );
00405
00411 PBoolean PostData(
00412 const PURL & url,
00413 PMIMEInfo & outMIME,
00414 const PString & data,
00415 PMIMEInfo & replyMIME,
00416 PString & replyBody,
00417 PBoolean persist = PTrue
00418 );
00419
00420 protected:
00421 PBoolean AssureConnect(const PURL & url, PMIMEInfo & outMIME);
00422 PBoolean InternalReadContentBody(
00423 PMIMEInfo & replyMIME,
00424 PAbstractArray & body
00425 );
00426
00427 PString userAgentName;
00428 };
00429
00431
00432
00437 class PMultipartFormInfo : public PObject
00438 {
00439 PCLASSINFO(PMultipartFormInfo, PObject);
00440 public:
00441 PMIMEInfo mime;
00442 PString body;
00443 };
00444
00445 PARRAY(PMultipartFormInfoArray, PMultipartFormInfo);
00446
00448
00449
00450 class PHTTPServer;
00451
00456 class PHTTPConnectionInfo : public PObject
00457 {
00458 PCLASSINFO(PHTTPConnectionInfo, PObject)
00459 public:
00460 PHTTPConnectionInfo();
00461
00462 PHTTP::Commands GetCommandCode() const { return commandCode; }
00463 const PString & GetCommandName() const { return commandName; }
00464
00465 const PURL & GetURL() const { return url; }
00466
00467 const PMIMEInfo & GetMIME() const { return mimeInfo; }
00468 void SetMIME(const PString & tag, const PString & value);
00469
00470 PBoolean IsCompatible(int major, int minor) const;
00471
00472 PBoolean IsPersistant() const { return isPersistant; }
00473 PBoolean WasPersistant() const { return wasPersistant; }
00474 PBoolean IsProxyConnection() const { return isProxyConnection; }
00475 int GetMajorVersion() const { return majorVersion; }
00476 int GetMinorVersion() const { return minorVersion; }
00477
00478 long GetEntityBodyLength() const { return entityBodyLength; }
00479
00482 PTimeInterval GetPersistenceTimeout() const { return persistenceTimeout; }
00483
00486 void SetPersistenceTimeout(const PTimeInterval & t) { persistenceTimeout = t; }
00487
00491 unsigned GetPersistenceMaximumTransations() const { return persistenceMaximum; }
00492
00496 void SetPersistenceMaximumTransations(unsigned m) { persistenceMaximum = m; }
00497
00498 const PMultipartFormInfoArray & GetMultipartFormInfo() const
00499 { return multipartFormInfoArray; }
00500
00501 void ResetMultipartFormInfo()
00502 { multipartFormInfoArray.RemoveAll(); }
00503
00504 PString GetEntityBody() const { return entityBody; }
00505
00506 protected:
00507 PBoolean Initialise(PHTTPServer & server, PString & args);
00508 void DecodeMultipartFormInfo(const PString & type, const PString & entityBody);
00509
00510 PHTTP::Commands commandCode;
00511 PString commandName;
00512 PURL url;
00513 PMIMEInfo mimeInfo;
00514 PBoolean isPersistant;
00515 PBoolean wasPersistant;
00516 PBoolean isProxyConnection;
00517 int majorVersion;
00518 int minorVersion;
00519 PString entityBody;
00520 long entityBodyLength;
00521 PTimeInterval persistenceTimeout;
00522 unsigned persistenceMaximum;
00523 PMultipartFormInfoArray multipartFormInfoArray;
00524
00525 friend class PHTTPServer;
00526 };
00527
00528
00530
00531
00544 class PHTTPServer : public PHTTP
00545 {
00546 PCLASSINFO(PHTTPServer, PHTTP)
00547
00548 public:
00556 PHTTPServer();
00557 PHTTPServer(
00558 const PHTTPSpace & urlSpace
00559 );
00560
00561
00562
00568 virtual PString GetServerName() const;
00569
00575 PHTTPSpace & GetURLSpace() { return urlSpace; }
00576
00578 void SetURLSpace(
00579 const PHTTPSpace & space
00580 );
00581
00582
00592 virtual PBoolean ProcessCommand();
00593
00605 virtual PBoolean OnGET(
00606 const PURL & url,
00607 const PMIMEInfo & info,
00608 const PHTTPConnectionInfo & conInfo
00609 );
00610
00611
00612
00624 virtual PBoolean OnHEAD(
00625 const PURL & url,
00626 const PMIMEInfo & info,
00627 const PHTTPConnectionInfo & conInfo
00628 );
00629
00641 virtual PBoolean OnPOST(
00642 const PURL & url,
00643 const PMIMEInfo & info,
00644 const PStringToString & data,
00645 const PHTTPConnectionInfo & conInfo
00646 );
00647
00660 virtual PBoolean OnProxy(
00661 const PHTTPConnectionInfo & conInfo
00662 );
00663
00664
00671 virtual PString ReadEntityBody();
00672
00678 virtual PBoolean OnUnknown(
00679 const PCaselessString & command,
00680 const PHTTPConnectionInfo & connectInfo
00681 );
00682
00701 PBoolean StartResponse(
00702 StatusCode code,
00703 PMIMEInfo & headers,
00704 long bodySize
00705 );
00706
00716 virtual PBoolean OnError(
00717 StatusCode code,
00718 const PCaselessString & extra,
00719 const PHTTPConnectionInfo & connectInfo
00720 );
00721
00724 void SetDefaultMIMEInfo(
00725 PMIMEInfo & info,
00726 const PHTTPConnectionInfo & connectInfo
00727 );
00728
00731 PHTTPConnectionInfo & GetConnectionInfo() { return connectInfo; }
00732
00733 protected:
00734 void Construct();
00735
00736 PHTTPSpace urlSpace;
00737 PHTTPConnectionInfo connectInfo;
00738 unsigned transactionCount;
00739 PTimeInterval nextTimeout;
00740 };
00741
00742
00744
00745
00750 class PHTTPRequest : public PObject
00751 {
00752 PCLASSINFO(PHTTPRequest, PObject)
00753
00754 public:
00755 PHTTPRequest(
00756 const PURL & url,
00757 const PMIMEInfo & inMIME,
00758 const PMultipartFormInfoArray & multipartFormInfo,
00759 PHTTPResource * resource,
00760 PHTTPServer & server
00761 );
00762
00763 PHTTPServer & server;
00764 const PURL & url;
00765 const PMIMEInfo & inMIME;
00766 const PMultipartFormInfoArray & multipartFormInfo;
00767 PHTTP::StatusCode code;
00768 PMIMEInfo outMIME;
00769 PString entityBody;
00770 PINDEX contentSize;
00771 PIPSocket::Address origin;
00772 PIPSocket::Address localAddr;
00773 WORD localPort;
00774 PHTTPResource * m_resource;
00775 };
00776
00777
00779
00780
00784 class PHTTPAuthority : public PObject
00785 {
00786 PCLASSINFO(PHTTPAuthority, PObject)
00787
00788 public:
00789
00796 virtual PString GetRealm(
00797 const PHTTPRequest & request
00798 ) const = 0;
00799
00806 virtual PBoolean Validate(
00807 const PHTTPRequest & request,
00808 const PString & authInfo
00809 ) const = 0;
00810
00820 virtual PBoolean IsActive() const;
00821
00822 protected:
00823 static void DecodeBasicAuthority(
00824 const PString & authInfo,
00825 PString & username,
00826 PString & password
00827 );
00828 };
00829
00830
00832
00833
00837 class PHTTPSimpleAuth : public PHTTPAuthority
00838 {
00839 PCLASSINFO(PHTTPSimpleAuth, PHTTPAuthority)
00840
00841 public:
00842 PHTTPSimpleAuth(
00843 const PString & realm,
00844 const PString & username,
00845 const PString & password
00846 );
00847
00848
00849
00850
00858 virtual PObject * Clone() const;
00859
00860
00861
00868 virtual PString GetRealm(
00869 const PHTTPRequest & request
00870 ) const;
00871
00878 virtual PBoolean Validate(
00879 const PHTTPRequest & request,
00880 const PString & authInfo
00881 ) const;
00882
00892 virtual PBoolean IsActive() const;
00893
00899 const PString & GetUserName() const { return username; }
00900
00906 const PString & GetPassword() const { return password; }
00907
00908
00909 protected:
00910 PString realm;
00911 PString username;
00912 PString password;
00913 };
00914
00915
00917
00918
00922 class PHTTPMultiSimpAuth : public PHTTPAuthority
00923 {
00924 PCLASSINFO(PHTTPMultiSimpAuth, PHTTPAuthority)
00925
00926 public:
00927 PHTTPMultiSimpAuth(
00928 const PString & realm
00929 );
00930 PHTTPMultiSimpAuth(
00931 const PString & realm,
00932 const PStringToString & userList
00933 );
00934
00935
00936
00937
00945 virtual PObject * Clone() const;
00946
00947
00948
00955 virtual PString GetRealm(
00956 const PHTTPRequest & request
00957 ) const;
00958
00965 virtual PBoolean Validate(
00966 const PHTTPRequest & request,
00967 const PString & authInfo
00968 ) const;
00969
00979 virtual PBoolean IsActive() const;
00980
00986 void AddUser(
00987 const PString & username,
00988 const PString & password
00989 );
00990
00991
00992 protected:
00993 PString realm;
00994 PStringToString users;
00995 };
00996
00997
00999
01000
01004 class PHTTPResource : public PObject
01005 {
01006 PCLASSINFO(PHTTPResource, PObject)
01007
01008 protected:
01009 PHTTPResource(
01010 const PURL & url
01011 );
01012 PHTTPResource(
01013 const PURL & url,
01014 const PHTTPAuthority & auth
01015 );
01016 PHTTPResource(
01017 const PURL & url,
01018 const PString & contentType
01019 );
01020 PHTTPResource(
01021 const PURL & url,
01022 const PString & contentType,
01023 const PHTTPAuthority & auth
01024 );
01025
01026
01027
01028 public:
01029 virtual ~PHTTPResource();
01030
01031
01032
01033
01039 const PURL & GetURL() const { return baseURL; }
01040
01046 const PString & GetContentType() const { return contentType; }
01047
01054 PHTTPAuthority * GetAuthority() const { return authority; }
01055
01058 void SetAuthority(
01059 const PHTTPAuthority & auth
01060 );
01061
01064 void ClearAuthority();
01065
01072 DWORD GetHitCount() const { return hitCount; }
01073
01074 void ClearHitCount() { hitCount = 0; }
01075
01076
01077
01089 virtual PBoolean OnGET(
01090 PHTTPServer & server,
01091 const PURL & url,
01092 const PMIMEInfo & info,
01093 const PHTTPConnectionInfo & conInfo
01094 );
01095
01105 virtual PBoolean OnGETData(
01106 PHTTPServer & server,
01107 const PURL & url,
01108 const PHTTPConnectionInfo & connectInfo,
01109 PHTTPRequest & request
01110 );
01111
01123 virtual PBoolean OnHEAD(
01124 PHTTPServer & server,
01125 const PURL & url,
01126 const PMIMEInfo & info,
01127 const PHTTPConnectionInfo & conInfo
01128 );
01129
01141 virtual PBoolean OnPOST(
01142 PHTTPServer & server,
01143 const PURL & url,
01144 const PMIMEInfo & info,
01145 const PStringToString & data,
01146 const PHTTPConnectionInfo & conInfo
01147 );
01148
01158 virtual PBoolean OnPOSTData(
01159 PHTTPRequest & request,
01160 const PStringToString & data
01161 );
01162
01169 virtual PBoolean IsModifiedSince(
01170 const PTime & when
01171 );
01172
01178 virtual PBoolean GetExpirationDate(
01179 PTime & when
01180 );
01181
01189 virtual PHTTPRequest * CreateRequest(
01190 const PURL & url,
01191 const PMIMEInfo & inMIME,
01192 const PMultipartFormInfoArray & multipartFormInfo,
01193 PHTTPServer & socket
01194 );
01195
01203 virtual PBoolean LoadHeaders(
01204 PHTTPRequest & request
01205 ) = 0;
01206
01212 virtual void SendData(
01213 PHTTPRequest & request
01214 );
01215
01224 virtual PBoolean LoadData(
01225 PHTTPRequest & request,
01226 PCharArray & data
01227 );
01228
01237 virtual PString LoadText(
01238 PHTTPRequest & request
01239 );
01240
01247 virtual void OnLoadedText(
01248 PHTTPRequest & request,
01249 PString & text
01250 );
01251
01260 virtual PBoolean Post(
01261 PHTTPRequest & request,
01262 const PStringToString & data,
01263 PHTML & replyMessage
01264 );
01265
01266
01267 protected:
01270 virtual PBoolean CheckAuthority(
01271 PHTTPServer & server,
01272 const PHTTPRequest & request,
01273 const PHTTPConnectionInfo & conInfo
01274 );
01275 static PBoolean CheckAuthority(
01276 PHTTPAuthority & authority,
01277 PHTTPServer & server,
01278 const PHTTPRequest & request,
01279 const PHTTPConnectionInfo & connectInfo
01280 );
01281
01282
01284 virtual PBoolean OnGETOrHEAD(
01285 PHTTPServer & server,
01286 const PURL & url,
01287 const PMIMEInfo & info,
01288 const PHTTPConnectionInfo & conInfo,
01289 PBoolean IsGet
01290 );
01291
01293 PURL baseURL;
01295 PString contentType;
01297 PHTTPAuthority * authority;
01299 volatile DWORD hitCount;
01300 };
01301
01302
01304
01305
01310 class PHTTPString : public PHTTPResource
01311 {
01312 PCLASSINFO(PHTTPString, PHTTPResource)
01313
01314 public:
01318 PHTTPString(
01319 const PURL & url
01320 );
01321 PHTTPString(
01322 const PURL & url,
01323 const PHTTPAuthority & auth
01324 );
01325 PHTTPString(
01326 const PURL & url,
01327 const PString & str
01328 );
01329 PHTTPString(
01330 const PURL & url,
01331 const PString & str,
01332 const PString & contentType
01333 );
01334 PHTTPString(
01335 const PURL & url,
01336 const PString & str,
01337 const PHTTPAuthority & auth
01338 );
01339 PHTTPString(
01340 const PURL & url,
01341 const PString & str,
01342 const PString & contentType,
01343 const PHTTPAuthority & auth
01344 );
01345
01346
01347
01355 virtual PBoolean LoadHeaders(
01356 PHTTPRequest & request
01357 );
01358
01367 virtual PString LoadText(
01368 PHTTPRequest & request
01369 );
01370
01371
01377 const PString & GetString() { return string; }
01378
01381 void SetString(
01382 const PString & str
01383 ) { string = str; }
01384
01385
01386 protected:
01387 PString string;
01388 };
01389
01390
01392
01393
01399 class PHTTPFile : public PHTTPResource
01400 {
01401 PCLASSINFO(PHTTPFile, PHTTPResource)
01402
01403 public:
01410 PHTTPFile(
01411 const PString & filename
01412 );
01413 PHTTPFile(
01414 const PString & filename,
01415 const PHTTPAuthority & auth
01416 );
01417 PHTTPFile(
01418 const PURL & url,
01419 const PFilePath & file
01420 );
01421 PHTTPFile(
01422 const PURL & url,
01423 const PFilePath & file,
01424 const PString & contentType
01425 );
01426 PHTTPFile(
01427 const PURL & url,
01428 const PFilePath & file,
01429 const PHTTPAuthority & auth
01430 );
01431 PHTTPFile(
01432 const PURL & url,
01433 const PFilePath & file,
01434 const PString & contentType,
01435 const PHTTPAuthority & auth
01436 );
01437
01438
01439
01445 virtual PHTTPRequest * CreateRequest(
01446 const PURL & url,
01447 const PMIMEInfo & inMIME,
01448 const PMultipartFormInfoArray & multipartFormInfo,
01449 PHTTPServer & socket
01450 );
01451
01459 virtual PBoolean LoadHeaders(
01460 PHTTPRequest & request
01461 );
01462
01468 virtual PBoolean LoadData(
01469 PHTTPRequest & request,
01470 PCharArray & data
01471 );
01472
01481 virtual PString LoadText(
01482 PHTTPRequest & request
01483 );
01484
01485
01486 protected:
01487 PHTTPFile(
01488 const PURL & url,
01489 int dummy
01490 );
01491
01492
01493
01494 PFilePath filePath;
01495 };
01496
01497
01498 class PHTTPFileRequest : public PHTTPRequest
01499 {
01500 PCLASSINFO(PHTTPFileRequest, PHTTPRequest)
01501 public:
01502 PHTTPFileRequest(
01503 const PURL & url,
01504 const PMIMEInfo & inMIME,
01505 const PMultipartFormInfoArray & multipartFormInfo,
01506 PHTTPResource * resource,
01507 PHTTPServer & server
01508 );
01509
01510 PFile file;
01511 };
01512
01513
01515
01516
01525 class PHTTPTailFile : public PHTTPFile
01526 {
01527 PCLASSINFO(PHTTPTailFile, PHTTPFile)
01528
01529 public:
01536 PHTTPTailFile(
01537 const PString & filename
01538 );
01539 PHTTPTailFile(
01540 const PString & filename,
01541 const PHTTPAuthority & auth
01542 );
01543 PHTTPTailFile(
01544 const PURL & url,
01545 const PFilePath & file
01546 );
01547 PHTTPTailFile(
01548 const PURL & url,
01549 const PFilePath & file,
01550 const PString & contentType
01551 );
01552 PHTTPTailFile(
01553 const PURL & url,
01554 const PFilePath & file,
01555 const PHTTPAuthority & auth
01556 );
01557 PHTTPTailFile(
01558 const PURL & url,
01559 const PFilePath & file,
01560 const PString & contentType,
01561 const PHTTPAuthority & auth
01562 );
01563
01564
01565
01573 virtual PBoolean LoadHeaders(
01574 PHTTPRequest & request
01575 );
01576
01582 virtual PBoolean LoadData(
01583 PHTTPRequest & request,
01584 PCharArray & data
01585 );
01586 };
01587
01588
01590
01591
01604 class PHTTPDirectory : public PHTTPFile
01605 {
01606 PCLASSINFO(PHTTPDirectory, PHTTPFile)
01607
01608 public:
01609 PHTTPDirectory(
01610 const PURL & url,
01611 const PDirectory & dir
01612 );
01613 PHTTPDirectory(
01614 const PURL & url,
01615 const PDirectory & dir,
01616 const PHTTPAuthority & auth
01617 );
01618
01619
01620
01621
01627 virtual PHTTPRequest * CreateRequest(
01628 const PURL & url,
01629 const PMIMEInfo & inMIME,
01630 const PMultipartFormInfoArray & multipartFormInfo,
01631 PHTTPServer & socket
01632 );
01633
01641 virtual PBoolean LoadHeaders(
01642 PHTTPRequest & request
01643 );
01644
01653 virtual PString LoadText(
01654 PHTTPRequest & request
01655 );
01656
01665 void EnableAuthorisation(const PString & realm);
01666
01669 void AllowDirectories(PBoolean enable = PTrue);
01670
01671 protected:
01672 PBoolean CheckAuthority(
01673 PHTTPServer & server,
01674 const PHTTPRequest & request,
01675 const PHTTPConnectionInfo & conInfo
01676 );
01677
01678 PBoolean FindAuthorisations(const PDirectory & dir, PString & realm, PStringToString & authorisations);
01679
01680 PDirectory basePath;
01681 PString authorisationRealm;
01682 PBoolean allowDirectoryListing;
01683 };
01684
01685
01686 class PHTTPDirRequest : public PHTTPFileRequest
01687 {
01688 PCLASSINFO(PHTTPDirRequest, PHTTPFileRequest)
01689 public:
01690 PHTTPDirRequest(
01691 const PURL & url,
01692 const PMIMEInfo & inMIME,
01693 const PMultipartFormInfoArray & multipartFormInfo,
01694 PHTTPResource * resource,
01695 PHTTPServer & server
01696 );
01697
01698 PString fakeIndex;
01699 PFilePath realPath;
01700 };
01701
01702 #endif // P_HTTP
01703
01704 #endif // PTLIB_HTTP_H
01705
01706
01707