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
#ifndef _PHTTP
00224
#define _PHTTP
00225
00226
#ifdef P_USE_PRAGMA
00227
#pragma interface
00228
#endif
00229
00230
#include <ptclib/inetprot.h>
00231
#include <ptclib/mime.h>
00232
#include <ptclib/url.h>
00233
#include <ptclib/html.h>
00234
#include <ptlib/ipsock.h>
00235
00236
00238
00239
00240
class PHTTPResource;
00241
00246 class PHTTPSpace :
public PContainer
00247 {
00248
PCONTAINERINFO(
PHTTPSpace,
PContainer)
00249
public:
00251
PHTTPSpace();
00252
00253
00254
00255 enum AddOptions {
00257
ErrorOnExist,
00259
Overwrite
00260 };
00261
00262
00274 BOOL AddResource(
00275
PHTTPResource * resource,
00276 AddOptions overwrite = ErrorOnExist
00278 );
00279
00287 BOOL DelResource(
00288
const PURL & url
00289 );
00290
00296
PHTTPResource * FindResource(
00297
const PURL & url
00298 );
00299
00302 void StartRead()
const
00303
{
mutex->
StartRead(); }
00304
00307 void EndRead()
const
00308
{
mutex->
EndRead(); }
00309
00312 void StartWrite()
const
00313
{
mutex->
StartWrite(); }
00314
00317 void EndWrite()
const
00318
{
mutex->
EndWrite(); }
00319
00320
00321
protected:
00322 PReadWriteMutex *
mutex;
00323
00324
class Node;
00325
PSORTED_LIST(ChildList,
Node);
00326 class Node :
public PString
00327 {
00328
PCLASSINFO(
Node,
PString)
00329
public:
00330
Node(
const PString & name,
Node * parentNode);
00331
~Node();
00332
00333 Node *
parent;
00334 ChildList
children;
00335 PHTTPResource *
resource;
00336 } *
root;
00337
00338
private:
00339 BOOL SetSize(PINDEX) {
return FALSE; }
00340 };
00341
00342
00344
00345
00349 class PHTTP :
public PInternetProtocol
00350 {
00351
PCLASSINFO(
PHTTP,
PInternetProtocol)
00352
00353
public:
00354
00355 enum Commands {
00356
00357
GET,
HEAD,
POST,
00358
00359
PUT,
DELETE,
TRACE,
OPTIONS,
00360
00361
CONNECT,
00362
NumCommands
00363 };
00364
00365 enum StatusCode {
00366
Continue = 100,
00367
SwitchingProtocols,
00368
RequestOK = 200,
00369
Created,
00370
Accepted,
00371
NonAuthoritativeInformation,
00372
NoContent,
00373
ResetContent,
00374
PartialContent,
00375
MultipleChoices = 300,
00376
MovedPermanently,
00377
MovedTemporarily,
00378
SeeOther,
00379
NotModified,
00380
UseProxy,
00381
BadRequest = 400,
00382
UnAuthorised,
00383
PaymentRequired,
00384
Forbidden,
00385
NotFound,
00386
MethodNotAllowed,
00387
NoneAcceptable,
00388
ProxyAuthenticationRequired,
00389
RequestTimeout,
00390
Conflict,
00391
Gone,
00392
LengthRequired,
00393
UnlessTrue,
00394
InternalServerError = 500,
00395
NotImplemented,
00396
BadGateway,
00397
ServiceUnavailable,
00398
GatewayTimeout
00399 };
00400
00401
00402 static const char *
const AllowTag;
00403 static const char *
const AuthorizationTag;
00404 static const char *
const ContentEncodingTag;
00405 static const char *
const ContentLengthTag;
00406 static const char *
const ContentTypeTag;
00407 static const char *
const DateTag;
00408 static const char *
const ExpiresTag;
00409 static const char *
const FromTag;
00410 static const char *
const IfModifiedSinceTag;
00411 static const char *
const LastModifiedTag;
00412 static const char *
const LocationTag;
00413 static const char *
const PragmaTag;
00414 static const char *
const PragmaNoCacheTag;
00415 static const char *
const RefererTag;
00416 static const char *
const ServerTag;
00417 static const char *
const UserAgentTag;
00418 static const char *
const WWWAuthenticateTag;
00419 static const char *
const MIMEVersionTag;
00420 static const char *
const ConnectionTag;
00421 static const char *
const KeepAliveTag;
00422 static const char *
const TransferEncodingTag;
00423 static const char *
const ChunkedTag;
00424 static const char *
const ProxyConnectionTag;
00425 static const char *
const ProxyAuthorizationTag;
00426 static const char *
const ProxyAuthenticateTag;
00427 static const char *
const ForwardedTag;
00428 static const char *
const SetCookieTag;
00429 static const char *
const CookieTag;
00430
00431
protected:
00434
PHTTP();
00435
00447
virtual PINDEX
ParseResponse(
00448
const PString & line
00449 );
00450 };
00451
00452
00454
00455
00476 class PHTTPClient :
public PHTTP
00477 {
00478
PCLASSINFO(
PHTTPClient,
PHTTP)
00479
00480
public:
00482
PHTTPClient();
00483
PHTTPClient(
00484
const PString &
userAgentName
00485 );
00486
00487
00488
00496
int ExecuteCommand(
00497 Commands cmd,
00498
const PURL & url,
00499
PMIMEInfo & outMIME,
00500
const PString & dataBody,
00501
PMIMEInfo & replyMime,
00502 BOOL persist = TRUE
00503 );
00504
int ExecuteCommand(
00505
const PString & cmdName,
00506
const PURL & url,
00507
PMIMEInfo & outMIME,
00508
const PString & dataBody,
00509
PMIMEInfo & replyMime,
00510 BOOL persist = TRUE
00511 );
00512
00514 BOOL
WriteCommand(
00515 Commands cmd,
00516
const PString & url,
00517
PMIMEInfo & outMIME,
00518
const PString & dataBody
00519 );
00520 BOOL WriteCommand(
00521
const PString & cmdName,
00522
const PString & url,
00523
PMIMEInfo & outMIME,
00524
const PString & dataBody
00525 );
00526
00528 BOOL
ReadResponse(
00529
PMIMEInfo & replyMIME
00530 );
00531
00533 BOOL
ReadContentBody(
00534
PMIMEInfo & replyMIME,
00535
PBYTEArray & body
00536 );
00537 BOOL ReadContentBody(
00538
PMIMEInfo & replyMIME,
00539
PString & body
00540 );
00541
00542
00548 BOOL
GetTextDocument(
00549
const PURL & url,
00550
PString & document,
00551 BOOL persist = TRUE
00552 );
00553
00559 BOOL
GetDocument(
00560
const PURL & url,
00561
PMIMEInfo & outMIME,
00562
PMIMEInfo & replyMIME,
00563 BOOL persist = TRUE
00564 );
00565
00571 BOOL
GetHeader(
00572
const PURL & url,
00573
PMIMEInfo & outMIME,
00574
PMIMEInfo & replyMIME,
00575 BOOL persist = TRUE
00576 );
00577
00578
00584 BOOL
PostData(
00585
const PURL & url,
00586
PMIMEInfo & outMIME,
00587
const PString & data,
00588
PMIMEInfo & replyMIME,
00589 BOOL persist = TRUE
00590 );
00591
00597 BOOL PostData(
00598
const PURL & url,
00599
PMIMEInfo & outMIME,
00600
const PString & data,
00601
PMIMEInfo & replyMIME,
00602
PString & replyBody,
00603 BOOL persist = TRUE
00604 );
00605
00606
protected:
00607 BOOL
AssureConnect(
const PURL & url,
PMIMEInfo & outMIME);
00608 BOOL
InternalReadContentBody(
00609
PMIMEInfo & replyMIME,
00610
PAbstractArray & body
00611 );
00612
00613 PString userAgentName;
00614 };
00615
00616
00618
00619
00624 class PMultipartFormInfo :
public PObject
00625 {
00626
PCLASSINFO(
PMultipartFormInfo,
PObject);
00627
public:
00628 PMIMEInfo mime;
00629 PString body;
00630 };
00631
00632
PARRAY(PMultipartFormInfoArray,
PMultipartFormInfo);
00633
00635
00636
00637
class PHTTPServer;
00638
00643 class PHTTPConnectionInfo :
public PObject
00644 {
00645
PCLASSINFO(
PHTTPConnectionInfo,
PObject)
00646
public:
00647
PHTTPConnectionInfo();
00648
00649 PHTTP::Commands
GetCommandCode()
const {
return commandCode; }
00650 const PString &
GetCommandName()
const {
return commandName; }
00651
00652 const PURL &
GetURL()
const {
return url; }
00653
00654 const PMIMEInfo &
GetMIME()
const {
return mimeInfo; }
00655
void SetMIME(
const PString & tag,
const PString & value);
00656
00657 BOOL IsCompatible(
int major,
int minor)
const;
00658
00659 BOOL
IsPersistant()
const {
return isPersistant; }
00660 BOOL
WasPersistant()
const {
return wasPersistant; }
00661 BOOL
IsProxyConnection()
const {
return isProxyConnection; }
00662 int GetMajorVersion()
const {
return majorVersion; }
00663 int GetMinorVersion()
const {
return minorVersion; }
00664
00665 long GetEntityBodyLength()
const {
return entityBodyLength; }
00666
00669 PTimeInterval GetPersistenceTimeout()
const {
return persistenceTimeout; }
00670
00673 void SetPersistenceTimeout(
const PTimeInterval & t) {
persistenceTimeout = t; }
00674
00678 unsigned GetPersistenceMaximumTransations()
const {
return persistenceMaximum; }
00679
00683 void SetPersistenceMaximumTransations(
unsigned m) {
persistenceMaximum = m; }
00684
00685 const PMultipartFormInfoArray &
GetMultipartFormInfo()
const
00686
{
return multipartFormInfoArray; }
00687
00688 void ResetMultipartFormInfo()
00689 {
multipartFormInfoArray.RemoveAll(); }
00690
00691 PString GetEntityBody()
const {
return entityBody; }
00692
00693
protected:
00694 BOOL Initialise(
PHTTPServer & server,
PString & args);
00695
void DecodeMultipartFormInfo(
const PString & type,
const PString & entityBody);
00696
00697 PHTTP::Commands
commandCode;
00698 PString commandName;
00699 PURL url;
00700 PMIMEInfo mimeInfo;
00701 BOOL
isPersistant;
00702 BOOL
wasPersistant;
00703 BOOL
isProxyConnection;
00704 int majorVersion;
00705 int minorVersion;
00706 PString entityBody;
00707 long entityBodyLength;
00708 PTimeInterval persistenceTimeout;
00709 unsigned persistenceMaximum;
00710 PMultipartFormInfoArray
multipartFormInfoArray;
00711
00712
friend class PHTTPServer;
00713 };
00714
00715
00717
00718
00731 class PHTTPServer :
public PHTTP
00732 {
00733
PCLASSINFO(
PHTTPServer,
PHTTP)
00734
00735
public:
00743
PHTTPServer();
00744
PHTTPServer(
00745
const PHTTPSpace &
urlSpace
00746 );
00747
00748
00749
00755
virtual PString GetServerName()
const;
00756
00762 PHTTPSpace &
GetURLSpace() {
return urlSpace; }
00763
00765
void SetURLSpace(
00766
const PHTTPSpace & space
00767 );
00768
00769
00779
virtual BOOL
ProcessCommand();
00780
00792
virtual BOOL OnGET(
00793
const PURL & url,
00794
const PMIMEInfo & info,
00795
const PHTTPConnectionInfo & conInfo
00796 );
00797
00798
00799
00811
virtual BOOL OnHEAD(
00812
const PURL & url,
00813
const PMIMEInfo & info,
00814
const PHTTPConnectionInfo & conInfo
00815 );
00816
00828
virtual BOOL OnPOST(
00829
const PURL & url,
00830
const PMIMEInfo & info,
00831
const PStringToString & data,
00832
const PHTTPConnectionInfo & conInfo
00833 );
00834
00847
virtual BOOL OnProxy(
00848
const PHTTPConnectionInfo & conInfo
00849 );
00850
00851
00858
virtual PString ReadEntityBody();
00859
00865
virtual BOOL OnUnknown(
00866
const PCaselessString & command,
00867
const PHTTPConnectionInfo & connectInfo
00868 );
00869
00888 BOOL StartResponse(
00889 StatusCode code,
00890
PMIMEInfo & headers,
00891
long bodySize
00892 );
00893
00903
virtual BOOL OnError(
00904 StatusCode code,
00905
const PCaselessString & extra,
00906
const PHTTPConnectionInfo & connectInfo
00907 );
00908
00911
void SetDefaultMIMEInfo(
00912
PMIMEInfo & info,
00913
const PHTTPConnectionInfo & connectInfo
00914 );
00915
00918 PHTTPConnectionInfo &
GetConnectionInfo() {
return connectInfo; }
00919
00920
protected:
00921
void Construct();
00922
00923 PHTTPSpace urlSpace;
00924 PHTTPConnectionInfo connectInfo;
00925 unsigned transactionCount;
00926 PTimeInterval nextTimeout;
00927 };
00928
00929
00931
00932
00937 class PHTTPRequest :
public PObject
00938 {
00939
PCLASSINFO(
PHTTPRequest,
PObject)
00940
00941
public:
00942
PHTTPRequest(
00943
const PURL &
url,
00944
const PMIMEInfo &
inMIME,
00945
const PMultipartFormInfoArray &
multipartFormInfo,
00946
PHTTPServer &
server
00947 );
00948
00949 PHTTPServer & server;
00950 const PURL & url;
00951 const PMIMEInfo & inMIME;
00952 const PMultipartFormInfoArray & multipartFormInfo;
00953 PHTTP::StatusCode
code;
00954 PMIMEInfo outMIME;
00955 PString entityBody;
00956 PINDEX
contentSize;
00957 PIPSocket::Address origin;
00958 PIPSocket::Address localAddr;
00959 WORD
localPort;
00960 };
00961
00962
00964
00965
00969 class PHTTPAuthority :
public PObject
00970 {
00971
PCLASSINFO(
PHTTPAuthority,
PObject)
00972
00973
public:
00974
00981
virtual PString GetRealm(
00982
const PHTTPRequest & request
00983 )
const = 0;
00984
00991
virtual BOOL
Validate(
00992
const PHTTPRequest & request,
00993
const PString & authInfo
00994 )
const = 0;
00995
01005
virtual BOOL
IsActive()
const;
01006
01007
protected:
01008
static void DecodeBasicAuthority(
01009
const PString & authInfo,
01010
PString & username,
01011
PString & password
01012 );
01013 };
01014
01015
01017
01018
01022 class PHTTPSimpleAuth :
public PHTTPAuthority
01023 {
01024
PCLASSINFO(
PHTTPSimpleAuth,
PHTTPAuthority)
01025
01026
public:
01027
PHTTPSimpleAuth(
01028
const PString &
realm,
01029
const PString &
username,
01030
const PString &
password
01031 );
01032
01033
01034
01035
01043
virtual PObject *
Clone()
const;
01044
01045
01046
01053
virtual PString GetRealm(
01054
const PHTTPRequest & request
01055 )
const;
01056
01063
virtual BOOL
Validate(
01064
const PHTTPRequest & request,
01065
const PString & authInfo
01066 )
const;
01067
01077
virtual BOOL
IsActive()
const;
01078
01084 const PString &
GetUserName()
const {
return username; }
01085
01091 const PString &
GetPassword()
const {
return password; }
01092
01093
01094
protected:
01095 PString realm;
01096 PString username;
01097 PString password;
01098 };
01099
01100
01102
01103
01107 class PHTTPMultiSimpAuth :
public PHTTPAuthority
01108 {
01109
PCLASSINFO(
PHTTPMultiSimpAuth,
PHTTPAuthority)
01110
01111
public:
01112
PHTTPMultiSimpAuth(
01113
const PString &
realm
01114 );
01115
PHTTPMultiSimpAuth(
01116
const PString & realm,
01117
const PStringToString & userList
01118 );
01119
01120
01121
01122
01130
virtual PObject *
Clone()
const;
01131
01132
01133
01140
virtual PString GetRealm(
01141
const PHTTPRequest & request
01142 )
const;
01143
01150
virtual BOOL
Validate(
01151
const PHTTPRequest & request,
01152
const PString & authInfo
01153 )
const;
01154
01164
virtual BOOL
IsActive()
const;
01165
01171
void AddUser(
01172
const PString & username,
01173
const PString & password
01174 );
01175
01176
01177
protected:
01178 PString realm;
01179 PStringToString users;
01180 };
01181
01182
01184
01185
01189 class PHTTPResource :
public PObject
01190 {
01191
PCLASSINFO(
PHTTPResource,
PObject)
01192
01193
protected:
01194
PHTTPResource(
01195
const PURL & url
01196 );
01197
PHTTPResource(
01198
const PURL & url,
01199
const PHTTPAuthority & auth
01200 );
01201
PHTTPResource(
01202
const PURL & url,
01203
const PString &
contentType
01204 );
01205
PHTTPResource(
01206
const PURL & url,
01207
const PString & contentType,
01208
const PHTTPAuthority & auth
01209 );
01210
01211
01212
01213
public:
01214
virtual ~PHTTPResource();
01215
01216
01217
01218
01224 const PURL &
GetURL()
const {
return baseURL; }
01225
01231 const PString &
GetContentType()
const {
return contentType; }
01232
01239 PHTTPAuthority *
GetAuthority()
const {
return authority; }
01240
01243
void SetAuthority(
01244
const PHTTPAuthority & auth
01245 );
01246
01249
void ClearAuthority();
01250
01257 DWORD
GetHitCount()
const {
return hitCount; }
01258
01259 void ClearHitCount() {
hitCount = 0; }
01260
01261
01262
01274
virtual BOOL OnGET(
01275
PHTTPServer & server,
01276
const PURL & url,
01277
const PMIMEInfo & info,
01278
const PHTTPConnectionInfo & conInfo
01279 );
01280
01290
virtual BOOL OnGETData(
01291
PHTTPServer & server,
01292
const PURL & url,
01293
const PHTTPConnectionInfo & connectInfo,
01294
PHTTPRequest & request
01295 );
01296
01308
virtual BOOL OnHEAD(
01309
PHTTPServer & server,
01310
const PURL & url,
01311
const PMIMEInfo & info,
01312
const PHTTPConnectionInfo & conInfo
01313 );
01314
01326
virtual BOOL OnPOST(
01327
PHTTPServer & server,
01328
const PURL & url,
01329
const PMIMEInfo & info,
01330
const PStringToString & data,
01331
const PHTTPConnectionInfo & conInfo
01332 );
01333
01343
virtual BOOL OnPOSTData(
01344
PHTTPRequest & request,
01345
const PStringToString & data
01346 );
01347
01354
virtual BOOL IsModifiedSince(
01355
const PTime & when
01356 );
01357
01363
virtual BOOL GetExpirationDate(
01364
PTime & when
01365 );
01366
01374
virtual PHTTPRequest * CreateRequest(
01375
const PURL & url,
01376
const PMIMEInfo & inMIME,
01377
const PMultipartFormInfoArray & multipartFormInfo,
01378
PHTTPServer & socket
01379 );
01380
01388
virtual BOOL LoadHeaders(
01389
PHTTPRequest & request
01390 ) = 0;
01391
01397
virtual void SendData(
01398
PHTTPRequest & request
01399 );
01400
01409
virtual BOOL LoadData(
01410
PHTTPRequest & request,
01411
PCharArray & data
01412 );
01413
01422
virtual PString LoadText(
01423
PHTTPRequest & request
01424 );
01425
01432
virtual void OnLoadedText(
01433
PHTTPRequest & request,
01434
PString & text
01435 );
01436
01445
virtual BOOL Post(
01446
PHTTPRequest & request,
01447
const PStringToString & data,
01448
PHTML & replyMessage
01449 );
01450
01451
01452
protected:
01455
virtual BOOL CheckAuthority(
01456
PHTTPServer & server,
01457
const PHTTPRequest & request,
01458
const PHTTPConnectionInfo & conInfo
01459 );
01460
static BOOL CheckAuthority(
01461
PHTTPAuthority & authority,
01462
PHTTPServer & server,
01463
const PHTTPRequest & request,
01464
const PHTTPConnectionInfo & connectInfo
01465 );
01466
01467
01469
virtual BOOL OnGETOrHEAD(
01470
PHTTPServer & server,
01471
const PURL & url,
01472
const PMIMEInfo & info,
01473
const PHTTPConnectionInfo & conInfo,
01474 BOOL IsGet
01475 );
01476
01478 PURL baseURL;
01480 PString contentType;
01482 PHTTPAuthority *
authority;
01484 volatile DWORD
hitCount;
01485 };
01486
01487
01489
01490
01495 class PHTTPString :
public PHTTPResource
01496 {
01497
PCLASSINFO(
PHTTPString,
PHTTPResource)
01498
01499
public:
01503
PHTTPString(
01504
const PURL & url
01505 );
01506
PHTTPString(
01507
const PURL & url,
01508
const PHTTPAuthority & auth
01509 );
01510
PHTTPString(
01511
const PURL & url,
01512
const PString & str
01513 );
01514
PHTTPString(
01515
const PURL & url,
01516
const PString & str,
01517
const PString & contentType
01518 );
01519
PHTTPString(
01520
const PURL & url,
01521
const PString & str,
01522
const PHTTPAuthority & auth
01523 );
01524
PHTTPString(
01525
const PURL & url,
01526
const PString & str,
01527
const PString & contentType,
01528
const PHTTPAuthority & auth
01529 );
01530
01531
01532
01540
virtual BOOL
LoadHeaders(
01541
PHTTPRequest & request
01542 );
01543
01552
virtual PString LoadText(
01553
PHTTPRequest & request
01554 );
01555
01556
01562 const PString &
GetString() {
return string; }
01563
01566 void SetString(
01567
const PString & str
01568 ) {
string = str; }
01569
01570
01571
protected:
01572 PString string;
01573 };
01574
01575
01577
01578
01584 class PHTTPFile :
public PHTTPResource
01585 {
01586
PCLASSINFO(
PHTTPFile,
PHTTPResource)
01587
01588
public:
01595
PHTTPFile(
01596
const PString & filename
01597 );
01598
PHTTPFile(
01599
const PString & filename,
01600
const PHTTPAuthority & auth
01601 );
01602
PHTTPFile(
01603
const PURL & url,
01604
const PFilePath & file
01605 );
01606
PHTTPFile(
01607
const PURL & url,
01608
const PFilePath & file,
01609
const PString & contentType
01610 );
01611
PHTTPFile(
01612
const PURL & url,
01613
const PFilePath & file,
01614
const PHTTPAuthority & auth
01615 );
01616
PHTTPFile(
01617
const PURL & url,
01618
const PFilePath & file,
01619
const PString & contentType,
01620
const PHTTPAuthority & auth
01621 );
01622
01623
01624
01630
virtual PHTTPRequest *
CreateRequest(
01631
const PURL & url,
01632
const PMIMEInfo & inMIME,
01633
const PMultipartFormInfoArray & multipartFormInfo,
01634
PHTTPServer & socket
01635 );
01636
01644
virtual BOOL
LoadHeaders(
01645
PHTTPRequest & request
01646 );
01647
01653
virtual BOOL
LoadData(
01654
PHTTPRequest & request,
01655
PCharArray & data
01656 );
01657
01666
virtual PString LoadText(
01667
PHTTPRequest & request
01668 );
01669
01670
01671
protected:
01672
PHTTPFile(
01673
const PURL & url,
01674
int dummy
01675 );
01676
01677
01678
01679 PFilePath filePath;
01680 };
01681
01682
01683 class PHTTPFileRequest :
public PHTTPRequest
01684 {
01685
PCLASSINFO(
PHTTPFileRequest,
PHTTPRequest)
01686
public:
01687
PHTTPFileRequest(
01688
const PURL & url,
01689
const PMIMEInfo & inMIME,
01690
const PMultipartFormInfoArray & multipartFormInfo,
01691
PHTTPServer & server
01692 );
01693
01694 PFile file;
01695 };
01696
01697
01699
01700
01709 class PHTTPTailFile :
public PHTTPFile
01710 {
01711
PCLASSINFO(
PHTTPTailFile,
PHTTPFile)
01712
01713
public:
01720
PHTTPTailFile(
01721
const PString & filename
01722 );
01723
PHTTPTailFile(
01724
const PString & filename,
01725
const PHTTPAuthority & auth
01726 );
01727
PHTTPTailFile(
01728
const PURL & url,
01729
const PFilePath & file
01730 );
01731
PHTTPTailFile(
01732
const PURL & url,
01733
const PFilePath & file,
01734
const PString & contentType
01735 );
01736
PHTTPTailFile(
01737
const PURL & url,
01738
const PFilePath & file,
01739
const PHTTPAuthority & auth
01740 );
01741
PHTTPTailFile(
01742
const PURL & url,
01743
const PFilePath & file,
01744
const PString & contentType,
01745
const PHTTPAuthority & auth
01746 );
01747
01748
01749
01757
virtual BOOL
LoadHeaders(
01758
PHTTPRequest & request
01759 );
01760
01766
virtual BOOL
LoadData(
01767
PHTTPRequest & request,
01768
PCharArray & data
01769 );
01770 };
01771
01772
01774
01775
01788 class PHTTPDirectory :
public PHTTPFile
01789 {
01790
PCLASSINFO(
PHTTPDirectory,
PHTTPFile)
01791
01792
public:
01793
PHTTPDirectory(
01794
const PURL & url,
01795
const PDirectory & dir
01796 );
01797
PHTTPDirectory(
01798
const PURL & url,
01799
const PDirectory & dir,
01800
const PHTTPAuthority & auth
01801 );
01802
01803
01804
01805
01811
virtual PHTTPRequest *
CreateRequest(
01812
const PURL & url,
01813
const PMIMEInfo & inMIME,
01814
const PMultipartFormInfoArray & multipartFormInfo,
01815
PHTTPServer & socket
01816 );
01817
01825
virtual BOOL
LoadHeaders(
01826
PHTTPRequest & request
01827 );
01828
01837
virtual PString LoadText(
01838
PHTTPRequest & request
01839 );
01840
01849
void EnableAuthorisation(
const PString & realm);
01850
01853
void AllowDirectories(BOOL enable = TRUE);
01854
01855
protected:
01856 BOOL
CheckAuthority(
01857
PHTTPServer & server,
01858
const PHTTPRequest & request,
01859
const PHTTPConnectionInfo & conInfo
01860 );
01861
01862 BOOL
FindAuthorisations(
const PDirectory & dir,
PString & realm,
PStringToString & authorisations);
01863
01864 PDirectory basePath;
01865 PString authorisationRealm;
01866 BOOL
allowDirectoryListing;
01867 };
01868
01869
01870 class PHTTPDirRequest :
public PHTTPFileRequest
01871 {
01872
PCLASSINFO(
PHTTPDirRequest,
PHTTPFileRequest)
01873
public:
01874
PHTTPDirRequest(
01875
const PURL & url,
01876
const PMIMEInfo & inMIME,
01877
const PMultipartFormInfoArray & multipartFormInfo,
01878
PHTTPServer & server
01879 );
01880
01881 PString fakeIndex;
01882 PFilePath realPath;
01883 };
01884
01885
01886
#endif
01887
01888
01889