PTLib  Version 2.10.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
http.h
Go to the documentation of this file.
1 /*
2  * http.h
3  *
4  * HyperText Transport Protocol classes.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 29065 $
27  * $Author: rjongbloed $
28  * $Date: 2013-02-11 18:26:26 -0600 (Mon, 11 Feb 2013) $
29  */
30 
31 #ifndef PTLIB_HTTP_H
32 #define PTLIB_HTTP_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #if P_HTTP
39 
40 #include <ptclib/inetprot.h>
41 #include <ptclib/mime.h>
42 #include <ptclib/url.h>
43 #include <ptlib/ipsock.h>
44 #include <ptlib/pfactory.h>
45 
46 
47 #include <ptclib/html.h>
48 
50 // PHTTPSpace
51 
52 class PHTTPResource;
53 
58 class PHTTPSpace : public PContainer
59 {
61  public:
63  PHTTPSpace();
64 
65 
66  // New functions for class.
67  enum AddOptions {
70  };
71 
72 
85  PHTTPResource * resource,
86  AddOptions overwrite = ErrorOnExist
88  );
89 
98  const PURL & url
99  );
100 
107  const PURL & url
108  );
109 
112  void StartRead() const
113  { mutex->StartRead(); }
114 
117  void EndRead() const
118  { mutex->EndRead(); }
119 
122  void StartWrite() const
123  { mutex->StartWrite(); }
124 
127  void EndWrite() const
128  { mutex->EndWrite(); }
129 
130 
131  protected:
133 
134  class Node;
135  PSORTED_LIST(ChildList, Node);
136  class Node : public PString
137  {
139  public:
140  Node(const PString & name, Node * parentNode);
141  ~Node();
142 
144  ChildList children;
146  } * root;
147 
148  private:
149  PBoolean SetSize(PINDEX) { return false; }
150 };
151 
152 #ifdef TRACE
153 #undef TRACE
154 #endif
155 
157 // PHTTP
158 
162 class PHTTP : public PInternetProtocol
163 {
165 
166  public:
167  // New functions for class.
168  enum Commands {
169  // HTTP/1.0 commands
171  // HTTP/1.1 commands
173  // HTTPS command
176  };
177 
178  enum StatusCode {
179  Continue = 100,
181  RequestOK = 200,
194  BadRequest = 400,
212  };
213 
214  // Common MIME header tags
215  static const PCaselessString & AllowTag();
216  static const PCaselessString & AuthorizationTag();
217  static const PCaselessString & ContentEncodingTag();
218  static const PCaselessString & ContentLengthTag();
220  static const PCaselessString & DateTag();
221  static const PCaselessString & ExpiresTag();
222  static const PCaselessString & FromTag();
223  static const PCaselessString & IfModifiedSinceTag();
224  static const PCaselessString & LastModifiedTag();
225  static const PCaselessString & LocationTag();
226  static const PCaselessString & PragmaTag();
227  static const PCaselessString & PragmaNoCacheTag();
228  static const PCaselessString & RefererTag();
229  static const PCaselessString & ServerTag();
230  static const PCaselessString & UserAgentTag();
231  static const PCaselessString & WWWAuthenticateTag();
232  static const PCaselessString & MIMEVersionTag();
233  static const PCaselessString & ConnectionTag();
234  static const PCaselessString & KeepAliveTag();
235  static const PCaselessString & TransferEncodingTag();
236  static const PCaselessString & ChunkedTag();
237  static const PCaselessString & ProxyConnectionTag();
238  static const PCaselessString & ProxyAuthorizationTag();
239  static const PCaselessString & ProxyAuthenticateTag();
240  static const PCaselessString & ForwardedTag();
241  static const PCaselessString & SetCookieTag();
242  static const PCaselessString & CookieTag();
243 
244  protected:
247  PHTTP();
248 
260  virtual PINDEX ParseResponse(
261  const PString & line
262  );
263 };
264 
265 
266 
268 {
269  PCLASSINFO(PHTTPClientAuthentication, PObject);
270  public:
271  class AuthObject {
272  public:
273  virtual ~AuthObject() { }
274  virtual PMIMEInfo & GetMIME() = 0;
275  virtual PString GetURI() = 0;
276  virtual PString GetEntityBody() = 0;
277  virtual PString GetMethod() = 0;
278  };
279 
281 
282  virtual Comparison Compare(
283  const PObject & other
284  ) const;
285 
286  virtual PBoolean Parse(
287  const PString & auth,
288  PBoolean proxy
289  ) = 0;
290 
291  virtual PBoolean Authorise(
292  AuthObject & pdu
293  ) const = 0;
294 
295  virtual PBoolean IsProxy() const { return isProxy; }
296 
297  virtual PString GetUsername() const { return username; }
298  virtual PString GetPassword() const { return password; }
299  virtual PString GetAuthRealm() const { return PString::Empty(); }
300 
301  virtual void SetUsername(const PString & user) { username = user; }
302  virtual void SetPassword(const PString & pass) { password = pass; }
303  virtual void SetAuthRealm(const PString &) { }
304 
305  PString GetAuthParam(const PString & auth, const char * name) const;
306  PString AsHex(PMessageDigest5::Code & digest) const;
307  PString AsHex(const PBYTEArray & data) const;
308 
309  static PHTTPClientAuthentication * ParseAuthenticationRequired(bool isProxy, const PMIMEInfo & line, PString & errorMsg);
310 
311 
312  protected:
316 };
317 
319 
321 {
322  public:
324  const PString & cmdName,
325  const PString & uri,
326  PMIMEInfo & mime,
327  const PString & body
328  );
329  virtual PMIMEInfo & GetMIME();
330  virtual PString GetURI();
331  virtual PString GetEntityBody();
332  virtual PString GetMethod();
333  protected:
338 };
339 
341 
343 {
345  public:
347 
348  virtual Comparison Compare(
349  const PObject & other
350  ) const;
351 
352  virtual PBoolean Parse(
353  const PString & auth,
354  PBoolean proxy
355  );
356 
357  virtual PBoolean Authorise(
358  AuthObject & pdu
359  ) const;
360 };
361 
363 
365 {
367  public:
369 
372  );
373 
374  virtual Comparison Compare(
375  const PObject & other
376  ) const;
377 
378  virtual PBoolean Parse(
379  const PString & auth,
380  PBoolean proxy
381  );
382 
383  virtual PBoolean Authorise(
384  AuthObject & pdu
385  ) const;
386 
387  virtual PString GetAuthRealm() const { return authRealm; }
388  virtual void SetAuthRealm(const PString & r) { authRealm = r; }
389 
390  enum Algorithm {
393  };
394  const PString & GetNonce() const { return nonce; }
395  Algorithm GetAlgorithm() const { return algorithm; }
396  const PString & GetOpaque() const { return opaque; }
397  bool GetStale() const { return stale; }
398 
399  protected:
404 
405  bool qopAuth;
407  bool stale;
410 };
411 
412 
414 // PHTTPClient
415 
436 class PHTTPClient : public PHTTP
437 {
439 
440  public:
442  PHTTPClient(
443  const PString & userAgentName = PString::Empty()
444  );
445 
446 
447  // New functions for class.
455  int ExecuteCommand(
456  Commands cmd,
457  const PURL & url,
458  PMIMEInfo & outMIME,
459  const PString & dataBody,
460  PMIMEInfo & replyMime
461  );
462  int ExecuteCommand(
463  const PString & cmdName,
464  const PURL & url,
465  PMIMEInfo & outMIME,
466  const PString & dataBody,
467  PMIMEInfo & replyMime
468  );
469 
471  bool WriteCommand(
472  Commands cmd,
473  const PString & url,
474  PMIMEInfo & outMIME,
475  const PString & dataBody
476  );
477  bool WriteCommand(
478  const PString & cmdName,
479  const PString & url,
480  PMIMEInfo & outMIME,
481  const PString & dataBody
482  );
483 
485  bool ReadResponse(
486  PMIMEInfo & replyMIME
487  );
488 
490  bool ReadContentBody(
491  PMIMEInfo & replyMIME
492  );
493 
495  bool ReadContentBody(
496  PMIMEInfo & replyMIME,
497  PString & body
498  );
499 
501  bool ReadContentBody(
502  PMIMEInfo & replyMIME,
503  PBYTEArray & body
504  );
505 
506 
513  bool GetDocument(
514  const PURL & url,
515  PMIMEInfo & outMIME,
516  PMIMEInfo & replyMIME
517  );
518  bool GetDocument(
519  const PURL & url,
520  PMIMEInfo & replyMIME
521  );
522 
530  bool GetTextDocument(
531  const PURL & url,
532  PString & document,
533  const PString & contentType = PString::Empty()
534  );
535 
541  bool GetHeader(
542  const PURL & url,
543  PMIMEInfo & outMIME,
544  PMIMEInfo & replyMIME
545  );
546 
547 
553  bool PostData(
554  const PURL & url,
555  const PStringToString & data
556  );
557 
563  bool PostData(
564  const PURL & url,
565  PMIMEInfo & outMIME,
566  const PString & data
567  );
568 
575  bool PostData(
576  const PURL & url,
577  PMIMEInfo & outMIME,
578  const PString & data,
579  PMIMEInfo & replyMIME
580  );
581 
587  bool PostData(
588  const PURL & url,
589  PMIMEInfo & outMIME,
590  const PString & data,
591  PMIMEInfo & replyMIME,
592  PString & replyBody
593  );
594 
600  bool PutTextDocument(
601  const PURL & url,
602  const PString & document,
603  const PString & contentType = PMIMEInfo::TextPlain()
604  );
605 
611  bool PutDocument(
612  const PURL & url,
613  PMIMEInfo & outMIME,
614  PMIMEInfo & replyMIME
615  );
616 
622  bool DeleteDocument(
623  const PURL & url
624  );
625 
629  const PString & userName,
630  const PString & password
631  );
632 
635  bool persist = true
636  ) { m_persist = persist; }
637 
639  bool GetPersistent() const { return m_persist; }
640 
641  protected:
642  bool AssureConnect(const PURL & url, PMIMEInfo & outMIME);
644  PMIMEInfo & replyMIME,
645  PAbstractArray * body
646  );
647 
649  bool m_persist;
653 };
654 
655 
657 // PHTTPConnectionInfo
658 
659 class PHTTPServer;
660 
666 {
668  public:
670 
672  const PString & GetCommandName() const { return commandName; }
673 
674  const PURL & GetURL() const { return url; }
675 
676  const PMIMEInfo & GetMIME() const { return mimeInfo; }
677  void SetMIME(const PString & tag, const PString & value);
678 
679  PBoolean IsCompatible(int major, int minor) const;
680 
681  bool IsPersistent() const { return isPersistent; }
682  bool WasPersistent() const { return wasPersistent; }
683  bool IsProxyConnection() const { return isProxyConnection; }
684  int GetMajorVersion() const { return majorVersion; }
685  int GetMinorVersion() const { return minorVersion; }
686 
687  long GetEntityBodyLength() const { return entityBodyLength; }
688 
692 
696 
701 
706 
708  { return m_multipartFormInfo; }
709 
712 
713  PString GetEntityBody() const { return entityBody; }
714 
715  protected:
716  PBoolean Initialise(PHTTPServer & server, PString & args);
718 
728  PString entityBody; // original entity body (POST only)
733 
734  friend class PHTTPServer;
735 };
736 
737 
739 // PHTTPServer
740 
762 class PHTTPServer : public PHTTP
763 {
765 
766  public:
774  PHTTPServer();
775  PHTTPServer(
776  const PHTTPSpace & urlSpace
777  );
778 
779 
780  // New functions for class.
786  virtual PString GetServerName() const;
787 
794 
796  void SetURLSpace(
797  const PHTTPSpace & space
798  );
799 
800 
810  virtual PBoolean ProcessCommand();
811 
823  virtual PBoolean OnGET(
824  const PURL & url,
825  const PMIMEInfo & info,
826  const PHTTPConnectionInfo & conInfo
827  );
828 
829 
830 
842  virtual PBoolean OnHEAD(
843  const PURL & url,
844  const PMIMEInfo & info,
845  const PHTTPConnectionInfo & conInfo
846  );
847 
859  virtual PBoolean OnPOST(
860  const PURL & url,
861  const PMIMEInfo & info,
862  const PStringToString & data,
863  const PHTTPConnectionInfo & conInfo
864  );
865 
878  virtual PBoolean OnProxy(
879  const PHTTPConnectionInfo & conInfo
880  );
881 
882 
889  virtual PString ReadEntityBody();
890 
896  virtual PBoolean OnUnknown(
897  const PCaselessString & command,
899  );
900 
920  StatusCode code,
921  PMIMEInfo & headers,
922  long bodySize
923  );
924 
934  virtual PBoolean OnError(
935  StatusCode code,
936  const PCaselessString & extra,
938  );
939 
942  void SetDefaultMIMEInfo(
943  PMIMEInfo & info,
945  );
946 
950 
951  protected:
952  void Construct();
953 
958 };
959 
960 
962 // PHTTPRequest
963 
968 class PHTTPRequest : public PObject
969 {
971 
972  public:
973  PHTTPRequest(
974  const PURL & url,
975  const PMIMEInfo & inMIME,
977  PHTTPResource * resource,
979  );
980 
982  const PURL & url;
983  const PMIMEInfo & inMIME;
988  PINDEX contentSize;
991  WORD localPort;
993 };
994 
995 
997 // PHTTPAuthority
998 
1002 class PHTTPAuthority : public PObject
1003 {
1005 
1006  public:
1007  // New functions for class.
1014  virtual PString GetRealm(
1015  const PHTTPRequest & request
1016  ) const = 0;
1017 
1024  virtual PBoolean Validate(
1025  const PHTTPRequest & request,
1026  const PString & authInfo
1027  ) const = 0;
1028 
1038  virtual PBoolean IsActive() const;
1039 
1040  protected:
1041  static void DecodeBasicAuthority(
1042  const PString & authInfo,
1043  PString & username,
1044  PString & password
1045  );
1046 };
1047 
1048 
1050 // PHTTPSimpleAuth
1051 
1056 {
1058 
1059  public:
1061  const PString & realm,
1062  const PString & username,
1063  const PString & password
1064  );
1065  // Construct the simple authorisation structure.
1066 
1067 
1068  // Overrides from class PObject.
1076  virtual PObject * Clone() const;
1077 
1078 
1079  // Overrides from class PHTTPAuthority.
1086  virtual PString GetRealm(
1087  const PHTTPRequest & request
1088  ) const;
1089 
1096  virtual PBoolean Validate(
1097  const PHTTPRequest & request,
1098  const PString & authInfo
1099  ) const;
1100 
1110  virtual PBoolean IsActive() const;
1111 
1117  const PString & GetUserName() const { return username; }
1118 
1124  const PString & GetPassword() const { return password; }
1125 
1126 
1127  protected:
1131 };
1132 
1133 
1135 // PHTTPMultiSimpAuth
1136 
1141 {
1143 
1144  public:
1146  const PString & realm
1147  );
1149  const PString & realm,
1150  const PStringToString & userList
1151  );
1152  // Construct the simple authorisation structure.
1153 
1154 
1155  // Overrides from class PObject.
1163  virtual PObject * Clone() const;
1164 
1165 
1166  // Overrides from class PHTTPAuthority.
1173  virtual PString GetRealm(
1174  const PHTTPRequest & request
1175  ) const;
1176 
1183  virtual PBoolean Validate(
1184  const PHTTPRequest & request,
1185  const PString & authInfo
1186  ) const;
1187 
1197  virtual PBoolean IsActive() const;
1198 
1204  void AddUser(
1205  const PString & username,
1206  const PString & password
1207  );
1208 
1209 
1210  protected:
1213 };
1214 
1215 
1217 // PHTTPResource
1218 
1222 class PHTTPResource : public PObject
1223 {
1225 
1226  protected:
1227  PHTTPResource(
1228  const PURL & url
1229  );
1230  PHTTPResource(
1231  const PURL & url,
1232  const PHTTPAuthority & auth
1233  );
1234  PHTTPResource(
1235  const PURL & url,
1236  const PString & contentType
1237  );
1238  PHTTPResource(
1239  const PURL & url,
1240  const PString & contentType,
1241  const PHTTPAuthority & auth
1242  );
1243  // Create a new HTTP Resource.
1244 
1245 
1246  public:
1247  virtual ~PHTTPResource();
1248  // Destroy the HTTP Resource.
1249 
1250 
1251  // New functions for class.
1257  const PURL & GetURL() const { return baseURL; }
1258 
1264  const PString & GetContentType() const { return contentType; }
1265 
1272  PHTTPAuthority * GetAuthority() const { return authority; }
1273 
1276  void SetAuthority(
1277  const PHTTPAuthority & auth
1278  );
1279 
1282  void ClearAuthority();
1283 
1290  DWORD GetHitCount() const { return hitCount; }
1291 
1292  void ClearHitCount() { hitCount = 0; }
1293  // Clear the hit count for the resource.
1294 
1295 
1307  virtual PBoolean OnGET(
1308  PHTTPServer & server,
1309  const PURL & url,
1310  const PMIMEInfo & info,
1311  const PHTTPConnectionInfo & conInfo
1312  );
1313 
1323  virtual PBoolean OnGETData(
1324  PHTTPServer & server,
1325  const PURL & url,
1326  const PHTTPConnectionInfo & connectInfo,
1327  PHTTPRequest & request
1328  );
1329 
1341  virtual PBoolean OnHEAD(
1342  PHTTPServer & server,
1343  const PURL & url,
1344  const PMIMEInfo & info,
1345  const PHTTPConnectionInfo & conInfo
1346  );
1347 
1359  virtual PBoolean OnPOST(
1360  PHTTPServer & server,
1361  const PURL & url,
1362  const PMIMEInfo & info,
1363  const PStringToString & data,
1364  const PHTTPConnectionInfo & conInfo
1365  );
1366 
1376  virtual PBoolean OnPOSTData(
1377  PHTTPRequest & request,
1378  const PStringToString & data
1379  );
1380 
1387  virtual PBoolean IsModifiedSince(
1388  const PTime & when
1389  );
1390 
1396  virtual PBoolean GetExpirationDate(
1397  PTime & when
1398  );
1399 
1407  virtual PHTTPRequest * CreateRequest(
1408  const PURL & url,
1409  const PMIMEInfo & inMIME,
1410  const PMultiPartList & multipartFormInfo,
1411  PHTTPServer & socket
1412  );
1413 
1421  virtual PBoolean LoadHeaders(
1422  PHTTPRequest & request
1423  ) = 0;
1424 
1430  virtual void SendData(
1431  PHTTPRequest & request
1432  );
1433 
1442  virtual PBoolean LoadData(
1443  PHTTPRequest & request,
1444  PCharArray & data
1445  );
1446 
1455  virtual PString LoadText(
1456  PHTTPRequest & request
1457  );
1458 
1465  virtual void OnLoadedText(
1466  PHTTPRequest & request,
1467  PString & text
1468  );
1469 
1478  virtual PBoolean Post(
1479  PHTTPRequest & request,
1480  const PStringToString & data,
1481  PHTML & replyMessage
1482  );
1483 
1484 
1485  protected:
1488  virtual PBoolean CheckAuthority(
1489  PHTTPServer & server,
1490  const PHTTPRequest & request,
1491  const PHTTPConnectionInfo & conInfo
1492  );
1493  static PBoolean CheckAuthority(
1495  PHTTPServer & server,
1496  const PHTTPRequest & request,
1497  const PHTTPConnectionInfo & connectInfo
1498  );
1499 
1500 
1502  virtual PBoolean OnGETOrHEAD(
1503  PHTTPServer & server,
1504  const PURL & url,
1505  const PMIMEInfo & info,
1506  const PHTTPConnectionInfo & conInfo,
1507  PBoolean isGet
1508  );
1509 
1510 
1514  volatile DWORD hitCount;
1515 };
1516 
1517 
1519 // PHTTPString
1520 
1526 {
1528 
1529  public:
1533  PHTTPString(
1534  const PURL & url // Name of the resource in URL space.
1535  );
1536  PHTTPString(
1537  const PURL & url, // Name of the resource in URL space.
1538  const PHTTPAuthority & auth // Authorisation for the resource.
1539  );
1540  PHTTPString(
1541  const PURL & url, // Name of the resource in URL space.
1542  const PString & str // String to return in this resource.
1543  );
1544  PHTTPString(
1545  const PURL & url, // Name of the resource in URL space.
1546  const PString & str, // String to return in this resource.
1547  const PString & contentType // MIME content type for the file.
1548  );
1549  PHTTPString(
1550  const PURL & url, // Name of the resource in URL space.
1551  const PString & str, // String to return in this resource.
1552  const PHTTPAuthority & auth // Authorisation for the resource.
1553  );
1554  PHTTPString(
1555  const PURL & url, // Name of the resource in URL space.
1556  const PString & str, // String to return in this resource.
1557  const PString & contentType, // MIME content type for the file.
1558  const PHTTPAuthority & auth // Authorisation for the resource.
1559  );
1560 
1561 
1562  // Overrides from class PHTTPResource
1570  virtual PBoolean LoadHeaders(
1571  PHTTPRequest & request // Information on this request.
1572  );
1573 
1582  virtual PString LoadText(
1583  PHTTPRequest & request // Information on this request.
1584  );
1585 
1586  // New functions for class.
1592  const PString & GetString() { return string; }
1593 
1597  const PString & str // New string for the resource.
1598  ) { string = str; }
1599 
1600 
1601  protected:
1603 };
1604 
1605 
1607 // PHTTPFile
1608 
1614 class PHTTPFile : public PHTTPResource
1615 {
1617 
1618  public:
1625  PHTTPFile(
1626  const PString & filename // file in file system and URL name.
1627  );
1628  PHTTPFile(
1629  const PString & filename, // file in file system and URL name.
1630  const PHTTPAuthority & auth // Authorisation for the resource.
1631  );
1632  PHTTPFile(
1633  const PURL & url, // Name of the resource in URL space.
1634  const PFilePath & file // Location of file in file system.
1635  );
1636  PHTTPFile(
1637  const PURL & url, // Name of the resource in URL space.
1638  const PFilePath & file, // Location of file in file system.
1639  const PString & contentType // MIME content type for the file.
1640  );
1641  PHTTPFile(
1642  const PURL & url, // Name of the resource in URL space.
1643  const PFilePath & file, // Location of file in file system.
1644  const PHTTPAuthority & auth // Authorisation for the resource.
1645  );
1646  PHTTPFile(
1647  const PURL & url, // Name of the resource in URL space.
1648  const PFilePath & file, // Location of file in file system.
1649  const PString & contentType, // MIME content type for the file.
1650  const PHTTPAuthority & auth // Authorisation for the resource.
1651  );
1652 
1653 
1654  // Overrides from class PHTTPResource
1660  virtual PHTTPRequest * CreateRequest(
1661  const PURL & url, // Universal Resource Locator for document.
1662  const PMIMEInfo & inMIME, // Extra MIME information in command.
1663  const PMultiPartList & multipartFormInfo,
1664  PHTTPServer & socket
1665  );
1666 
1674  virtual PBoolean LoadHeaders(
1675  PHTTPRequest & request // Information on this request.
1676  );
1677 
1683  virtual PBoolean LoadData(
1684  PHTTPRequest & request, // Information on this request.
1685  PCharArray & data // Data used in reply.
1686  );
1687 
1696  virtual PString LoadText(
1697  PHTTPRequest & request // Information on this request.
1698  );
1699 
1700 
1701  protected:
1702  PHTTPFile(
1703  const PURL & url, // Name of the resource in URL space.
1704  int dummy
1705  );
1706  // Constructor used by PHTTPDirectory
1707 
1708 
1710 };
1711 
1712 
1714 {
1716  public:
1718  const PURL & url, // Universal Resource Locator for document.
1719  const PMIMEInfo & inMIME, // Extra MIME information in command.
1721  PHTTPResource * resource,
1723  );
1724 
1726 };
1727 
1728 
1730 // PHTTPTailFile
1731 
1740 class PHTTPTailFile : public PHTTPFile
1741 {
1743 
1744  public:
1751  PHTTPTailFile(
1752  const PString & filename // file in file system and URL name.
1753  );
1754  PHTTPTailFile(
1755  const PString & filename, // file in file system and URL name.
1756  const PHTTPAuthority & auth // Authorisation for the resource.
1757  );
1758  PHTTPTailFile(
1759  const PURL & url, // Name of the resource in URL space.
1760  const PFilePath & file // Location of file in file system.
1761  );
1762  PHTTPTailFile(
1763  const PURL & url, // Name of the resource in URL space.
1764  const PFilePath & file, // Location of file in file system.
1765  const PString & contentType // MIME content type for the file.
1766  );
1767  PHTTPTailFile(
1768  const PURL & url, // Name of the resource in URL space.
1769  const PFilePath & file, // Location of file in file system.
1770  const PHTTPAuthority & auth // Authorisation for the resource.
1771  );
1772  PHTTPTailFile(
1773  const PURL & url, // Name of the resource in URL space.
1774  const PFilePath & file, // Location of file in file system.
1775  const PString & contentType, // MIME content type for the file.
1776  const PHTTPAuthority & auth // Authorisation for the resource.
1777  );
1778 
1779 
1780  // Overrides from class PHTTPResource
1788  virtual PBoolean LoadHeaders(
1789  PHTTPRequest & request // Information on this request.
1790  );
1791 
1797  virtual PBoolean LoadData(
1798  PHTTPRequest & request, // Information on this request.
1799  PCharArray & data // Data used in reply.
1800  );
1801 };
1802 
1803 
1805 // PHTTPDirectory
1806 
1820 {
1822 
1823  public:
1825  const PURL & url,
1826  const PDirectory & dir
1827  );
1829  const PURL & url,
1830  const PDirectory & dir,
1831  const PHTTPAuthority & auth
1832  );
1833  // Construct a new directory resource for HTTP.
1834 
1835 
1836  // Overrides from class PHTTPResource
1842  virtual PHTTPRequest * CreateRequest(
1843  const PURL & url, // Universal Resource Locator for document.
1844  const PMIMEInfo & inMIME, // Extra MIME information in command.
1845  const PMultiPartList & multipartFormInfo,
1846  PHTTPServer & socket
1847  );
1848 
1856  virtual PBoolean LoadHeaders(
1857  PHTTPRequest & request
1858  );
1859 
1868  virtual PString LoadText(
1869  PHTTPRequest & request
1870  );
1871 
1880  void EnableAuthorisation(const PString & realm);
1881 
1884  void AllowDirectories(PBoolean enable = true);
1885 
1886  protected:
1888  PHTTPServer & server, // Server to send response to.
1889  const PHTTPRequest & request, // Information on this request.
1890  const PHTTPConnectionInfo & conInfo // Information on the connection
1891  );
1892 
1893  PBoolean FindAuthorisations(const PDirectory & dir, PString & realm, PStringToString & authorisations);
1894 
1898 };
1899 
1900 
1902 {
1904  public:
1906  const PURL & url, // Universal Resource Locator for document.
1907  const PMIMEInfo & inMIME, // Extra MIME information in command.
1909  PHTTPResource * resource,
1911  );
1912 
1915 };
1916 
1917 
1918 PFACTORY_LOAD(PURL_HttpLoader);
1919 
1920 
1921 #endif // P_HTTP
1922 
1923 #endif // PTLIB_HTTP_H
1924 
1925 
1926 // End Of File ///////////////////////////////////////////////////////////////