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
00233
00234
00235
00236 #ifndef _PHTTP
00237 #define _PHTTP
00238
00239 #ifdef P_USE_PRAGMA
00240 #pragma interface
00241 #endif
00242
00243 #include <ptbuildopts.h>
00244
00245 #include <ptclib/inetprot.h>
00246 #include <ptclib/mime.h>
00247 #include <ptclib/url.h>
00248 #include <ptlib/ipsock.h>
00249
00250 #ifdef P_HTTPSVC
00251
00252 #include <ptclib/html.h>
00253
00255
00256
00257 class PHTTPResource;
00258
00263 class PHTTPSpace : public PContainer
00264 {
00265 PCONTAINERINFO(PHTTPSpace, PContainer)
00266 public:
00268 PHTTPSpace();
00269
00270
00271
00272 enum AddOptions {
00274 ErrorOnExist,
00276 Overwrite
00277 };
00278
00279
00291 BOOL AddResource(
00292 PHTTPResource * resource,
00293 AddOptions overwrite = ErrorOnExist
00295 );
00296
00304 BOOL DelResource(
00305 const PURL & url
00306 );
00307
00313 PHTTPResource * FindResource(
00314 const PURL & url
00315 );
00316
00319 void StartRead() const
00320 { mutex->StartRead(); }
00321
00324 void EndRead() const
00325 { mutex->EndRead(); }
00326
00329 void StartWrite() const
00330 { mutex->StartWrite(); }
00331
00334 void EndWrite() const
00335 { mutex->EndWrite(); }
00336
00337
00338 protected:
00339 PReadWriteMutex * mutex;
00340
00341 class Node;
00342 PSORTED_LIST(ChildList, Node);
00343 class Node : public PString
00344 {
00345 PCLASSINFO(Node, PString)
00346 public:
00347 Node(const PString & name, Node * parentNode);
00348 ~Node();
00349
00350 Node * parent;
00351 ChildList children;
00352 PHTTPResource * resource;
00353 } * root;
00354
00355 private:
00356 BOOL SetSize(PINDEX) { return FALSE; }
00357 };
00358
00359 #endif // P_HTTPSVC
00360
00361 #ifdef _WIN32_WCE
00362 #undef TRACE
00363 #endif
00364
00366
00367
00371 class PHTTP : public PInternetProtocol
00372 {
00373 PCLASSINFO(PHTTP, PInternetProtocol)
00374
00375 public:
00376
00377 enum Commands {
00378
00379 GET, HEAD, POST,
00380
00381 PUT, DELETE, TRACE, OPTIONS,
00382
00383 CONNECT,
00384 NumCommands
00385 };
00386
00387 enum StatusCode {
00388 Continue = 100,
00389 SwitchingProtocols,
00390 RequestOK = 200,
00391 Created,
00392 Accepted,
00393 NonAuthoritativeInformation,
00394 NoContent,
00395 ResetContent,
00396 PartialContent,
00397 MultipleChoices = 300,
00398 MovedPermanently,
00399 MovedTemporarily,
00400 SeeOther,
00401 NotModified,
00402 UseProxy,
00403 BadRequest = 400,
00404 UnAuthorised,
00405 PaymentRequired,
00406 Forbidden,
00407 NotFound,
00408 MethodNotAllowed,
00409 NoneAcceptable,
00410 ProxyAuthenticationRequired,
00411 RequestTimeout,
00412 Conflict,
00413 Gone,
00414 LengthRequired,
00415 UnlessTrue,
00416 InternalServerError = 500,
00417 NotImplemented,
00418 BadGateway,
00419 ServiceUnavailable,
00420 GatewayTimeout
00421 };
00422
00423
00424 static const PString & AllowTag();
00425 static const PString & AuthorizationTag();
00426 static const PString & ContentEncodingTag();
00427 static const PString & ContentLengthTag();
00428 static const PString & ContentTypeTag();
00429 static const PString & DateTag();
00430 static const PString & ExpiresTag();
00431 static const PString & FromTag();
00432 static const PString & IfModifiedSinceTag();
00433 static const PString & LastModifiedTag();
00434 static const PString & LocationTag();
00435 static const PString & PragmaTag();
00436 static const PString & PragmaNoCacheTag();
00437 static const PString & RefererTag();
00438 static const PString & ServerTag();
00439 static const PString & UserAgentTag();
00440 static const PString & WWWAuthenticateTag();
00441 static const PString & MIMEVersionTag();
00442 static const PString & ConnectionTag();
00443 static const PString & KeepAliveTag();
00444 static const PString & TransferEncodingTag();
00445 static const PString & ChunkedTag();
00446 static const PString & ProxyConnectionTag();
00447 static const PString & ProxyAuthorizationTag();
00448 static const PString & ProxyAuthenticateTag();
00449 static const PString & ForwardedTag();
00450 static const PString & SetCookieTag();
00451 static const PString & CookieTag();
00452
00453 protected:
00456 PHTTP();
00457
00469 virtual PINDEX ParseResponse(
00470 const PString & line
00471 );
00472 };
00473
00474
00476
00477
00498 class PHTTPClient : public PHTTP
00499 {
00500 PCLASSINFO(PHTTPClient, PHTTP)
00501
00502 public:
00504 PHTTPClient();
00505 PHTTPClient(
00506 const PString & userAgentName
00507 );
00508
00509
00510
00518 int ExecuteCommand(
00519 Commands cmd,
00520 const PURL & url,
00521 PMIMEInfo & outMIME,
00522 const PString & dataBody,
00523 PMIMEInfo & replyMime,
00524 BOOL persist = TRUE
00525 );
00526 int ExecuteCommand(
00527 const PString & cmdName,
00528 const PURL & url,
00529 PMIMEInfo & outMIME,
00530 const PString & dataBody,
00531 PMIMEInfo & replyMime,
00532 BOOL persist = TRUE
00533 );
00534
00536 BOOL WriteCommand(
00537 Commands cmd,
00538 const PString & url,
00539 PMIMEInfo & outMIME,
00540 const PString & dataBody
00541 );
00542 BOOL WriteCommand(
00543 const PString & cmdName,
00544 const PString & url,
00545 PMIMEInfo & outMIME,
00546 const PString & dataBody
00547 );
00548
00550 BOOL ReadResponse(
00551 PMIMEInfo & replyMIME
00552 );
00553
00555 BOOL ReadContentBody(
00556 PMIMEInfo & replyMIME,
00557 PBYTEArray & body
00558 );
00559 BOOL ReadContentBody(
00560 PMIMEInfo & replyMIME,
00561 PString & body
00562 );
00563
00564
00570 BOOL GetTextDocument(
00571 const PURL & url,
00572 PString & document,
00573 BOOL persist = TRUE
00574 );
00575
00581 BOOL GetDocument(
00582 const PURL & url,
00583 PMIMEInfo & outMIME,
00584 PMIMEInfo & replyMIME,
00585 BOOL persist = TRUE
00586 );
00587
00593 BOOL GetHeader(
00594 const PURL & url,
00595 PMIMEInfo & outMIME,
00596 PMIMEInfo & replyMIME,
00597 BOOL persist = TRUE
00598 );
00599
00600
00606 BOOL PostData(
00607 const PURL & url,
00608 PMIMEInfo & outMIME,
00609 const PString & data,
00610 PMIMEInfo & replyMIME,
00611 BOOL persist = TRUE
00612 );
00613
00619 BOOL PostData(
00620 const PURL & url,
00621 PMIMEInfo & outMIME,
00622 const PString & data,
00623 PMIMEInfo & replyMIME,
00624 PString & replyBody,
00625 BOOL persist = TRUE
00626 );
00627
00628 protected:
00629 BOOL AssureConnect(const PURL & url, PMIMEInfo & outMIME);
00630 BOOL InternalReadContentBody(
00631 PMIMEInfo & replyMIME,
00632 PAbstractArray & body
00633 );
00634
00635 PString userAgentName;
00636 };
00637
00638 #ifdef P_HTTPSVC
00639
00641
00642
00647 class PMultipartFormInfo : public PObject
00648 {
00649 PCLASSINFO(PMultipartFormInfo, PObject);
00650 public:
00651 PMIMEInfo mime;
00652 PString body;
00653 };
00654
00655 PARRAY(PMultipartFormInfoArray, PMultipartFormInfo);
00656
00658
00659
00660 class PHTTPServer;
00661
00666 class PHTTPConnectionInfo : public PObject
00667 {
00668 PCLASSINFO(PHTTPConnectionInfo, PObject)
00669 public:
00670 PHTTPConnectionInfo();
00671
00672 PHTTP::Commands GetCommandCode() const { return commandCode; }
00673 const PString & GetCommandName() const { return commandName; }
00674
00675 const PURL & GetURL() const { return url; }
00676
00677 const PMIMEInfo & GetMIME() const { return mimeInfo; }
00678 void SetMIME(const PString & tag, const PString & value);
00679
00680 BOOL IsCompatible(int major, int minor) const;
00681
00682 BOOL IsPersistant() const { return isPersistant; }
00683 BOOL WasPersistant() const { return wasPersistant; }
00684 BOOL IsProxyConnection() const { return isProxyConnection; }
00685 int GetMajorVersion() const { return majorVersion; }
00686 int GetMinorVersion() const { return minorVersion; }
00687
00688 long GetEntityBodyLength() const { return entityBodyLength; }
00689
00692 PTimeInterval GetPersistenceTimeout() const { return persistenceTimeout; }
00693
00696 void SetPersistenceTimeout(const PTimeInterval & t) { persistenceTimeout = t; }
00697
00701 unsigned GetPersistenceMaximumTransations() const { return persistenceMaximum; }
00702
00706 void SetPersistenceMaximumTransations(unsigned m) { persistenceMaximum = m; }
00707
00708 const PMultipartFormInfoArray & GetMultipartFormInfo() const
00709 { return multipartFormInfoArray; }
00710
00711 void ResetMultipartFormInfo()
00712 { multipartFormInfoArray.RemoveAll(); }
00713
00714 PString GetEntityBody() const { return entityBody; }
00715
00716 protected:
00717 BOOL Initialise(PHTTPServer & server, PString & args);
00718 void DecodeMultipartFormInfo(const PString & type, const PString & entityBody);
00719
00720 PHTTP::Commands commandCode;
00721 PString commandName;
00722 PURL url;
00723 PMIMEInfo mimeInfo;
00724 BOOL isPersistant;
00725 BOOL wasPersistant;
00726 BOOL isProxyConnection;
00727 int majorVersion;
00728 int minorVersion;
00729 PString entityBody;
00730 long entityBodyLength;
00731 PTimeInterval persistenceTimeout;
00732 unsigned persistenceMaximum;
00733 PMultipartFormInfoArray multipartFormInfoArray;
00734
00735 friend class PHTTPServer;
00736 };
00737
00738
00740
00741
00754 class PHTTPServer : public PHTTP
00755 {
00756 PCLASSINFO(PHTTPServer, PHTTP)
00757
00758 public:
00766 PHTTPServer();
00767 PHTTPServer(
00768 const PHTTPSpace & urlSpace
00769 );
00770
00771
00772
00778 virtual PString GetServerName() const;
00779
00785 PHTTPSpace & GetURLSpace() { return urlSpace; }
00786
00788 void SetURLSpace(
00789 const PHTTPSpace & space
00790 );
00791
00792
00802 virtual BOOL ProcessCommand();
00803
00815 virtual BOOL OnGET(
00816 const PURL & url,
00817 const PMIMEInfo & info,
00818 const PHTTPConnectionInfo & conInfo
00819 );
00820
00821
00822
00834 virtual BOOL OnHEAD(
00835 const PURL & url,
00836 const PMIMEInfo & info,
00837 const PHTTPConnectionInfo & conInfo
00838 );
00839
00851 virtual BOOL OnPOST(
00852 const PURL & url,
00853 const PMIMEInfo & info,
00854 const PStringToString & data,
00855 const PHTTPConnectionInfo & conInfo
00856 );
00857
00870 virtual BOOL OnProxy(
00871 const PHTTPConnectionInfo & conInfo
00872 );
00873
00874
00881 virtual PString ReadEntityBody();
00882
00888 virtual BOOL OnUnknown(
00889 const PCaselessString & command,
00890 const PHTTPConnectionInfo & connectInfo
00891 );
00892
00911 BOOL StartResponse(
00912 StatusCode code,
00913 PMIMEInfo & headers,
00914 long bodySize
00915 );
00916
00926 virtual BOOL OnError(
00927 StatusCode code,
00928 const PCaselessString & extra,
00929 const PHTTPConnectionInfo & connectInfo
00930 );
00931
00934 void SetDefaultMIMEInfo(
00935 PMIMEInfo & info,
00936 const PHTTPConnectionInfo & connectInfo
00937 );
00938
00941 PHTTPConnectionInfo & GetConnectionInfo() { return connectInfo; }
00942
00943 protected:
00944 void Construct();
00945
00946 PHTTPSpace urlSpace;
00947 PHTTPConnectionInfo connectInfo;
00948 unsigned transactionCount;
00949 PTimeInterval nextTimeout;
00950 };
00951
00952
00954
00955
00960 class PHTTPRequest : public PObject
00961 {
00962 PCLASSINFO(PHTTPRequest, PObject)
00963
00964 public:
00965 PHTTPRequest(
00966 const PURL & url,
00967 const PMIMEInfo & inMIME,
00968 const PMultipartFormInfoArray & multipartFormInfo,
00969 PHTTPServer & server
00970 );
00971
00972 PHTTPServer & server;
00973 const PURL & url;
00974 const PMIMEInfo & inMIME;
00975 const PMultipartFormInfoArray & multipartFormInfo;
00976 PHTTP::StatusCode code;
00977 PMIMEInfo outMIME;
00978 PString entityBody;
00979 PINDEX contentSize;
00980 PIPSocket::Address origin;
00981 PIPSocket::Address localAddr;
00982 WORD localPort;
00983 };
00984
00985
00987
00988
00992 class PHTTPAuthority : public PObject
00993 {
00994 PCLASSINFO(PHTTPAuthority, PObject)
00995
00996 public:
00997
01004 virtual PString GetRealm(
01005 const PHTTPRequest & request
01006 ) const = 0;
01007
01014 virtual BOOL Validate(
01015 const PHTTPRequest & request,
01016 const PString & authInfo
01017 ) const = 0;
01018
01028 virtual BOOL IsActive() const;
01029
01030 protected:
01031 static void DecodeBasicAuthority(
01032 const PString & authInfo,
01033 PString & username,
01034 PString & password
01035 );
01036 };
01037
01038
01040
01041
01045 class PHTTPSimpleAuth : public PHTTPAuthority
01046 {
01047 PCLASSINFO(PHTTPSimpleAuth, PHTTPAuthority)
01048
01049 public:
01050 PHTTPSimpleAuth(
01051 const PString & realm,
01052 const PString & username,
01053 const PString & password
01054 );
01055
01056
01057
01058
01066 virtual PObject * Clone() const;
01067
01068
01069
01076 virtual PString GetRealm(
01077 const PHTTPRequest & request
01078 ) const;
01079
01086 virtual BOOL Validate(
01087 const PHTTPRequest & request,
01088 const PString & authInfo
01089 ) const;
01090
01100 virtual BOOL IsActive() const;
01101
01107 const PString & GetUserName() const { return username; }
01108
01114 const PString & GetPassword() const { return password; }
01115
01116
01117 protected:
01118 PString realm;
01119 PString username;
01120 PString password;
01121 };
01122
01123
01125
01126
01130 class PHTTPMultiSimpAuth : public PHTTPAuthority
01131 {
01132 PCLASSINFO(PHTTPMultiSimpAuth, PHTTPAuthority)
01133
01134 public:
01135 PHTTPMultiSimpAuth(
01136 const PString & realm
01137 );
01138 PHTTPMultiSimpAuth(
01139 const PString & realm,
01140 const PStringToString & userList
01141 );
01142
01143
01144
01145
01153 virtual PObject * Clone() const;
01154
01155
01156
01163 virtual PString GetRealm(
01164 const PHTTPRequest & request
01165 ) const;
01166
01173 virtual BOOL Validate(
01174 const PHTTPRequest & request,
01175 const PString & authInfo
01176 ) const;
01177
01187 virtual BOOL IsActive() const;
01188
01194 void AddUser(
01195 const PString & username,
01196 const PString & password
01197 );
01198
01199
01200 protected:
01201 PString realm;
01202 PStringToString users;
01203 };
01204
01205
01207
01208
01212 class PHTTPResource : public PObject
01213 {
01214 PCLASSINFO(PHTTPResource, PObject)
01215
01216 protected:
01217 PHTTPResource(
01218 const PURL & url
01219 );
01220 PHTTPResource(
01221 const PURL & url,
01222 const PHTTPAuthority & auth
01223 );
01224 PHTTPResource(
01225 const PURL & url,
01226 const PString & contentType
01227 );
01228 PHTTPResource(
01229 const PURL & url,
01230 const PString & contentType,
01231 const PHTTPAuthority & auth
01232 );
01233
01234
01235
01236 public:
01237 virtual ~PHTTPResource();
01238
01239
01240
01241
01247 const PURL & GetURL() const { return baseURL; }
01248
01254 const PString & GetContentType() const { return contentType; }
01255
01262 PHTTPAuthority * GetAuthority() const { return authority; }
01263
01266 void SetAuthority(
01267 const PHTTPAuthority & auth
01268 );
01269
01272 void ClearAuthority();
01273
01280 DWORD GetHitCount() const { return hitCount; }
01281
01282 void ClearHitCount() { hitCount = 0; }
01283
01284
01285
01297 virtual BOOL OnGET(
01298 PHTTPServer & server,
01299 const PURL & url,
01300 const PMIMEInfo & info,
01301 const PHTTPConnectionInfo & conInfo
01302 );
01303
01313 virtual BOOL OnGETData(
01314 PHTTPServer & server,
01315 const PURL & url,
01316 const PHTTPConnectionInfo & connectInfo,
01317 PHTTPRequest & request
01318 );
01319
01331 virtual BOOL OnHEAD(
01332 PHTTPServer & server,
01333 const PURL & url,
01334 const PMIMEInfo & info,
01335 const PHTTPConnectionInfo & conInfo
01336 );
01337
01349 virtual BOOL OnPOST(
01350 PHTTPServer & server,
01351 const PURL & url,
01352 const PMIMEInfo & info,
01353 const PStringToString & data,
01354 const PHTTPConnectionInfo & conInfo
01355 );
01356
01366 virtual BOOL OnPOSTData(
01367 PHTTPRequest & request,
01368 const PStringToString & data
01369 );
01370
01377 virtual BOOL IsModifiedSince(
01378 const PTime & when
01379 );
01380
01386 virtual BOOL GetExpirationDate(
01387 PTime & when
01388 );
01389
01397 virtual PHTTPRequest * CreateRequest(
01398 const PURL & url,
01399 const PMIMEInfo & inMIME,
01400 const PMultipartFormInfoArray & multipartFormInfo,
01401 PHTTPServer & socket
01402 );
01403
01411 virtual BOOL LoadHeaders(
01412 PHTTPRequest & request
01413 ) = 0;
01414
01420 virtual void SendData(
01421 PHTTPRequest & request
01422 );
01423
01432 virtual BOOL LoadData(
01433 PHTTPRequest & request,
01434 PCharArray & data
01435 );
01436
01445 virtual PString LoadText(
01446 PHTTPRequest & request
01447 );
01448
01455 virtual void OnLoadedText(
01456 PHTTPRequest & request,
01457 PString & text
01458 );
01459
01468 virtual BOOL Post(
01469 PHTTPRequest & request,
01470 const PStringToString & data,
01471 PHTML & replyMessage
01472 );
01473
01474
01475 protected:
01478 virtual BOOL CheckAuthority(
01479 PHTTPServer & server,
01480 const PHTTPRequest & request,
01481 const PHTTPConnectionInfo & conInfo
01482 );
01483 static BOOL CheckAuthority(
01484 PHTTPAuthority & authority,
01485 PHTTPServer & server,
01486 const PHTTPRequest & request,
01487 const PHTTPConnectionInfo & connectInfo
01488 );
01489
01490
01492 virtual BOOL OnGETOrHEAD(
01493 PHTTPServer & server,
01494 const PURL & url,
01495 const PMIMEInfo & info,
01496 const PHTTPConnectionInfo & conInfo,
01497 BOOL IsGet
01498 );
01499
01501 PURL baseURL;
01503 PString contentType;
01505 PHTTPAuthority * authority;
01507 volatile DWORD hitCount;
01508 };
01509
01510
01512
01513
01518 class PHTTPString : public PHTTPResource
01519 {
01520 PCLASSINFO(PHTTPString, PHTTPResource)
01521
01522 public:
01526 PHTTPString(
01527 const PURL & url
01528 );
01529 PHTTPString(
01530 const PURL & url,
01531 const PHTTPAuthority & auth
01532 );
01533 PHTTPString(
01534 const PURL & url,
01535 const PString & str
01536 );
01537 PHTTPString(
01538 const PURL & url,
01539 const PString & str,
01540 const PString & contentType
01541 );
01542 PHTTPString(
01543 const PURL & url,
01544 const PString & str,
01545 const PHTTPAuthority & auth
01546 );
01547 PHTTPString(
01548 const PURL & url,
01549 const PString & str,
01550 const PString & contentType,
01551 const PHTTPAuthority & auth
01552 );
01553
01554
01555
01563 virtual BOOL LoadHeaders(
01564 PHTTPRequest & request
01565 );
01566
01575 virtual PString LoadText(
01576 PHTTPRequest & request
01577 );
01578
01579
01585 const PString & GetString() { return string; }
01586
01589 void SetString(
01590 const PString & str
01591 ) { string = str; }
01592
01593
01594 protected:
01595 PString string;
01596 };
01597
01598
01600
01601
01607 class PHTTPFile : public PHTTPResource
01608 {
01609 PCLASSINFO(PHTTPFile, PHTTPResource)
01610
01611 public:
01618 PHTTPFile(
01619 const PString & filename
01620 );
01621 PHTTPFile(
01622 const PString & filename,
01623 const PHTTPAuthority & auth
01624 );
01625 PHTTPFile(
01626 const PURL & url,
01627 const PFilePath & file
01628 );
01629 PHTTPFile(
01630 const PURL & url,
01631 const PFilePath & file,
01632 const PString & contentType
01633 );
01634 PHTTPFile(
01635 const PURL & url,
01636 const PFilePath & file,
01637 const PHTTPAuthority & auth
01638 );
01639 PHTTPFile(
01640 const PURL & url,
01641 const PFilePath & file,
01642 const PString & contentType,
01643 const PHTTPAuthority & auth
01644 );
01645
01646
01647
01653 virtual PHTTPRequest * CreateRequest(
01654 const PURL & url,
01655 const PMIMEInfo & inMIME,
01656 const PMultipartFormInfoArray & multipartFormInfo,
01657 PHTTPServer & socket
01658 );
01659
01667 virtual BOOL LoadHeaders(
01668 PHTTPRequest & request
01669 );
01670
01676 virtual BOOL LoadData(
01677 PHTTPRequest & request,
01678 PCharArray & data
01679 );
01680
01689 virtual PString LoadText(
01690 PHTTPRequest & request
01691 );
01692
01693
01694 protected:
01695 PHTTPFile(
01696 const PURL & url,
01697 int dummy
01698 );
01699
01700
01701
01702 PFilePath filePath;
01703 };
01704
01705
01706 class PHTTPFileRequest : public PHTTPRequest
01707 {
01708 PCLASSINFO(PHTTPFileRequest, PHTTPRequest)
01709 public:
01710 PHTTPFileRequest(
01711 const PURL & url,
01712 const PMIMEInfo & inMIME,
01713 const PMultipartFormInfoArray & multipartFormInfo,
01714 PHTTPServer & server
01715 );
01716
01717 PFile file;
01718 };
01719
01720
01722
01723
01732 class PHTTPTailFile : public PHTTPFile
01733 {
01734 PCLASSINFO(PHTTPTailFile, PHTTPFile)
01735
01736 public:
01743 PHTTPTailFile(
01744 const PString & filename
01745 );
01746 PHTTPTailFile(
01747 const PString & filename,
01748 const PHTTPAuthority & auth
01749 );
01750 PHTTPTailFile(
01751 const PURL & url,
01752 const PFilePath & file
01753 );
01754 PHTTPTailFile(
01755 const PURL & url,
01756 const PFilePath & file,
01757 const PString & contentType
01758 );
01759 PHTTPTailFile(
01760 const PURL & url,
01761 const PFilePath & file,
01762 const PHTTPAuthority & auth
01763 );
01764 PHTTPTailFile(
01765 const PURL & url,
01766 const PFilePath & file,
01767 const PString & contentType,
01768 const PHTTPAuthority & auth
01769 );
01770
01771
01772
01780 virtual BOOL LoadHeaders(
01781 PHTTPRequest & request
01782 );
01783
01789 virtual BOOL LoadData(
01790 PHTTPRequest & request,
01791 PCharArray & data
01792 );
01793 };
01794
01795
01797
01798
01811 class PHTTPDirectory : public PHTTPFile
01812 {
01813 PCLASSINFO(PHTTPDirectory, PHTTPFile)
01814
01815 public:
01816 PHTTPDirectory(
01817 const PURL & url,
01818 const PDirectory & dir
01819 );
01820 PHTTPDirectory(
01821 const PURL & url,
01822 const PDirectory & dir,
01823 const PHTTPAuthority & auth
01824 );
01825
01826
01827
01828
01834 virtual PHTTPRequest * CreateRequest(
01835 const PURL & url,
01836 const PMIMEInfo & inMIME,
01837 const PMultipartFormInfoArray & multipartFormInfo,
01838 PHTTPServer & socket
01839 );
01840
01848 virtual BOOL LoadHeaders(
01849 PHTTPRequest & request
01850 );
01851
01860 virtual PString LoadText(
01861 PHTTPRequest & request
01862 );
01863
01872 void EnableAuthorisation(const PString & realm);
01873
01876 void AllowDirectories(BOOL enable = TRUE);
01877
01878 protected:
01879 BOOL CheckAuthority(
01880 PHTTPServer & server,
01881 const PHTTPRequest & request,
01882 const PHTTPConnectionInfo & conInfo
01883 );
01884
01885 BOOL FindAuthorisations(const PDirectory & dir, PString & realm, PStringToString & authorisations);
01886
01887 PDirectory basePath;
01888 PString authorisationRealm;
01889 BOOL allowDirectoryListing;
01890 };
01891
01892
01893 class PHTTPDirRequest : public PHTTPFileRequest
01894 {
01895 PCLASSINFO(PHTTPDirRequest, PHTTPFileRequest)
01896 public:
01897 PHTTPDirRequest(
01898 const PURL & url,
01899 const PMIMEInfo & inMIME,
01900 const PMultipartFormInfoArray & multipartFormInfo,
01901 PHTTPServer & server
01902 );
01903
01904 PString fakeIndex;
01905 PFilePath realPath;
01906 };
01907
01908 #endif // P_HTTPSVC
01909
01910 #endif
01911
01912
01913