PTLib  Version 2.10.4
 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: 26045 $
27  * $Author: rjongbloed $
28  * $Date: 2011-06-19 20:28:39 -0500 (Sun, 19 Jun 2011) $
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 
472  Commands cmd,
473  const PString & url,
474  PMIMEInfo & outMIME,
475  const PString & dataBody
476  );
478  const PString & cmdName,
479  const PString & url,
480  PMIMEInfo & outMIME,
481  const PString & dataBody
482  );
483 
486  PMIMEInfo & replyMIME
487  );
488 
491  PMIMEInfo & replyMIME,
492  PBYTEArray & body
493  );
495  PMIMEInfo & replyMIME,
496  PString & body
497  );
498 
499 
509  const PURL & url,
510  PString & document,
511  const PString & contentType = PString::Empty()
512  );
513 
520  const PURL & url,
521  PMIMEInfo & outMIME,
522  PMIMEInfo & replyMIME
523  );
524 
531  const PURL & url,
532  PMIMEInfo & outMIME,
533  PMIMEInfo & replyMIME
534  );
535 
536 
543  const PURL & url,
544  PMIMEInfo & outMIME,
545  const PString & data,
546  PMIMEInfo & replyMIME
547  );
548 
555  const PURL & url,
556  PMIMEInfo & outMIME,
557  const PString & data,
558  PMIMEInfo & replyMIME,
559  PString & replyBody
560  );
561 
567  bool PutTextDocument(
568  const PURL & url,
569  const PString & document,
570  const PString & contentType = PMIMEInfo::TextPlain()
571  );
572 
578  bool PutDocument(
579  const PURL & url,
580  PMIMEInfo & outMIME,
581  PMIMEInfo & replyMIME
582  );
583 
589  bool DeleteDocument(
590  const PURL & url
591  );
592 
596  const PString & userName,
597  const PString & password
598  );
599 
602  bool persist = true
603  ) { m_persist = persist; }
604 
606  bool GetPersistent() const { return m_persist; }
607 
608  protected:
609  PBoolean AssureConnect(const PURL & url, PMIMEInfo & outMIME);
611  PMIMEInfo & replyMIME,
612  PAbstractArray * body
613  );
614 
616  bool m_persist;
620 };
621 
622 
624 // PHTTPConnectionInfo
625 
626 class PHTTPServer;
627 
633 {
635  public:
637 
639  const PString & GetCommandName() const { return commandName; }
640 
641  const PURL & GetURL() const { return url; }
642 
643  const PMIMEInfo & GetMIME() const { return mimeInfo; }
644  void SetMIME(const PString & tag, const PString & value);
645 
646  PBoolean IsCompatible(int major, int minor) const;
647 
648  bool IsPersistent() const { return isPersistent; }
649  bool WasPersistent() const { return wasPersistent; }
650  bool IsProxyConnection() const { return isProxyConnection; }
651  int GetMajorVersion() const { return majorVersion; }
652  int GetMinorVersion() const { return minorVersion; }
653 
654  long GetEntityBodyLength() const { return entityBodyLength; }
655 
659 
663 
668 
673 
675  { return m_multipartFormInfo; }
676 
679 
680  PString GetEntityBody() const { return entityBody; }
681 
682  protected:
683  PBoolean Initialise(PHTTPServer & server, PString & args);
685 
695  PString entityBody; // original entity body (POST only)
700 
701  friend class PHTTPServer;
702 };
703 
704 
706 // PHTTPServer
707 
729 class PHTTPServer : public PHTTP
730 {
732 
733  public:
741  PHTTPServer();
742  PHTTPServer(
743  const PHTTPSpace & urlSpace
744  );
745 
746 
747  // New functions for class.
753  virtual PString GetServerName() const;
754 
761 
763  void SetURLSpace(
764  const PHTTPSpace & space
765  );
766 
767 
777  virtual PBoolean ProcessCommand();
778 
790  virtual PBoolean OnGET(
791  const PURL & url,
792  const PMIMEInfo & info,
793  const PHTTPConnectionInfo & conInfo
794  );
795 
796 
797 
809  virtual PBoolean OnHEAD(
810  const PURL & url,
811  const PMIMEInfo & info,
812  const PHTTPConnectionInfo & conInfo
813  );
814 
826  virtual PBoolean OnPOST(
827  const PURL & url,
828  const PMIMEInfo & info,
829  const PStringToString & data,
830  const PHTTPConnectionInfo & conInfo
831  );
832 
845  virtual PBoolean OnProxy(
846  const PHTTPConnectionInfo & conInfo
847  );
848 
849 
856  virtual PString ReadEntityBody();
857 
863  virtual PBoolean OnUnknown(
864  const PCaselessString & command,
866  );
867 
887  StatusCode code,
888  PMIMEInfo & headers,
889  long bodySize
890  );
891 
901  virtual PBoolean OnError(
902  StatusCode code,
903  const PCaselessString & extra,
905  );
906 
909  void SetDefaultMIMEInfo(
910  PMIMEInfo & info,
912  );
913 
917 
918  protected:
919  void Construct();
920 
925 };
926 
927 
929 // PHTTPRequest
930 
935 class PHTTPRequest : public PObject
936 {
938 
939  public:
940  PHTTPRequest(
941  const PURL & url,
942  const PMIMEInfo & inMIME,
944  PHTTPResource * resource,
946  );
947 
949  const PURL & url;
950  const PMIMEInfo & inMIME;
955  PINDEX contentSize;
958  WORD localPort;
960 };
961 
962 
964 // PHTTPAuthority
965 
969 class PHTTPAuthority : public PObject
970 {
972 
973  public:
974  // New functions for class.
981  virtual PString GetRealm(
982  const PHTTPRequest & request
983  ) const = 0;
984 
991  virtual PBoolean Validate(
992  const PHTTPRequest & request,
993  const PString & authInfo
994  ) const = 0;
995 
1005  virtual PBoolean IsActive() const;
1006 
1007  protected:
1008  static void DecodeBasicAuthority(
1009  const PString & authInfo,
1010  PString & username,
1011  PString & password
1012  );
1013 };
1014 
1015 
1017 // PHTTPSimpleAuth
1018 
1023 {
1025 
1026  public:
1028  const PString & realm,
1029  const PString & username,
1030  const PString & password
1031  );
1032  // Construct the simple authorisation structure.
1033 
1034 
1035  // Overrides from class PObject.
1043  virtual PObject * Clone() const;
1044 
1045 
1046  // Overrides from class PHTTPAuthority.
1053  virtual PString GetRealm(
1054  const PHTTPRequest & request
1055  ) const;
1056 
1063  virtual PBoolean Validate(
1064  const PHTTPRequest & request,
1065  const PString & authInfo
1066  ) const;
1067 
1077  virtual PBoolean IsActive() const;
1078 
1084  const PString & GetUserName() const { return username; }
1085 
1091  const PString & GetPassword() const { return password; }
1092 
1093 
1094  protected:
1098 };
1099 
1100 
1102 // PHTTPMultiSimpAuth
1103 
1108 {
1110 
1111  public:
1113  const PString & realm
1114  );
1116  const PString & realm,
1117  const PStringToString & userList
1118  );
1119  // Construct the simple authorisation structure.
1120 
1121 
1122  // Overrides from class PObject.
1130  virtual PObject * Clone() const;
1131 
1132 
1133  // Overrides from class PHTTPAuthority.
1140  virtual PString GetRealm(
1141  const PHTTPRequest & request
1142  ) const;
1143 
1150  virtual PBoolean Validate(
1151  const PHTTPRequest & request,
1152  const PString & authInfo
1153  ) const;
1154 
1164  virtual PBoolean IsActive() const;
1165 
1171  void AddUser(
1172  const PString & username,
1173  const PString & password
1174  );
1175 
1176 
1177  protected:
1180 };
1181 
1182 
1184 // PHTTPResource
1185 
1189 class PHTTPResource : public PObject
1190 {
1192 
1193  protected:
1194  PHTTPResource(
1195  const PURL & url
1196  );
1197  PHTTPResource(
1198  const PURL & url,
1199  const PHTTPAuthority & auth
1200  );
1201  PHTTPResource(
1202  const PURL & url,
1203  const PString & contentType
1204  );
1205  PHTTPResource(
1206  const PURL & url,
1207  const PString & contentType,
1208  const PHTTPAuthority & auth
1209  );
1210  // Create a new HTTP Resource.
1211 
1212 
1213  public:
1214  virtual ~PHTTPResource();
1215  // Destroy the HTTP Resource.
1216 
1217 
1218  // New functions for class.
1224  const PURL & GetURL() const { return baseURL; }
1225 
1231  const PString & GetContentType() const { return contentType; }
1232 
1239  PHTTPAuthority * GetAuthority() const { return authority; }
1240 
1243  void SetAuthority(
1244  const PHTTPAuthority & auth
1245  );
1246 
1249  void ClearAuthority();
1250 
1257  DWORD GetHitCount() const { return hitCount; }
1258 
1259  void ClearHitCount() { hitCount = 0; }
1260  // Clear the hit count for the resource.
1261 
1262 
1274  virtual PBoolean OnGET(
1275  PHTTPServer & server,
1276  const PURL & url,
1277  const PMIMEInfo & info,
1278  const PHTTPConnectionInfo & conInfo
1279  );
1280 
1290  virtual PBoolean OnGETData(
1291  PHTTPServer & server,
1292  const PURL & url,
1293  const PHTTPConnectionInfo & connectInfo,
1294  PHTTPRequest & request
1295  );
1296 
1308  virtual PBoolean OnHEAD(
1309  PHTTPServer & server,
1310  const PURL & url,
1311  const PMIMEInfo & info,
1312  const PHTTPConnectionInfo & conInfo
1313  );
1314 
1326  virtual PBoolean OnPOST(
1327  PHTTPServer & server,
1328  const PURL & url,
1329  const PMIMEInfo & info,
1330  const PStringToString & data,
1331  const PHTTPConnectionInfo & conInfo
1332  );
1333 
1343  virtual PBoolean OnPOSTData(
1344  PHTTPRequest & request,
1345  const PStringToString & data
1346  );
1347 
1354  virtual PBoolean IsModifiedSince(
1355  const PTime & when
1356  );
1357 
1363  virtual PBoolean GetExpirationDate(
1364  PTime & when
1365  );
1366 
1374  virtual PHTTPRequest * CreateRequest(
1375  const PURL & url,
1376  const PMIMEInfo & inMIME,
1377  const PMultiPartList & multipartFormInfo,
1378  PHTTPServer & socket
1379  );
1380 
1388  virtual PBoolean LoadHeaders(
1389  PHTTPRequest & request
1390  ) = 0;
1391 
1397  virtual void SendData(
1398  PHTTPRequest & request
1399  );
1400 
1409  virtual PBoolean LoadData(
1410  PHTTPRequest & request,
1411  PCharArray & data
1412  );
1413 
1422  virtual PString LoadText(
1423  PHTTPRequest & request
1424  );
1425 
1432  virtual void OnLoadedText(
1433  PHTTPRequest & request,
1434  PString & text
1435  );
1436 
1445  virtual PBoolean Post(
1446  PHTTPRequest & request,
1447  const PStringToString & data,
1448  PHTML & replyMessage
1449  );
1450 
1451 
1452  protected:
1455  virtual PBoolean CheckAuthority(
1456  PHTTPServer & server,
1457  const PHTTPRequest & request,
1458  const PHTTPConnectionInfo & conInfo
1459  );
1460  static PBoolean CheckAuthority(
1462  PHTTPServer & server,
1463  const PHTTPRequest & request,
1464  const PHTTPConnectionInfo & connectInfo
1465  );
1466 
1467 
1469  virtual PBoolean OnGETOrHEAD(
1470  PHTTPServer & server,
1471  const PURL & url,
1472  const PMIMEInfo & info,
1473  const PHTTPConnectionInfo & conInfo,
1474  PBoolean isGet
1475  );
1476 
1477 
1481  volatile DWORD hitCount;
1482 };
1483 
1484 
1486 // PHTTPString
1487 
1493 {
1495 
1496  public:
1500  PHTTPString(
1501  const PURL & url // Name of the resource in URL space.
1502  );
1503  PHTTPString(
1504  const PURL & url, // Name of the resource in URL space.
1505  const PHTTPAuthority & auth // Authorisation for the resource.
1506  );
1507  PHTTPString(
1508  const PURL & url, // Name of the resource in URL space.
1509  const PString & str // String to return in this resource.
1510  );
1511  PHTTPString(
1512  const PURL & url, // Name of the resource in URL space.
1513  const PString & str, // String to return in this resource.
1514  const PString & contentType // MIME content type for the file.
1515  );
1516  PHTTPString(
1517  const PURL & url, // Name of the resource in URL space.
1518  const PString & str, // String to return in this resource.
1519  const PHTTPAuthority & auth // Authorisation for the resource.
1520  );
1521  PHTTPString(
1522  const PURL & url, // Name of the resource in URL space.
1523  const PString & str, // String to return in this resource.
1524  const PString & contentType, // MIME content type for the file.
1525  const PHTTPAuthority & auth // Authorisation for the resource.
1526  );
1527 
1528 
1529  // Overrides from class PHTTPResource
1537  virtual PBoolean LoadHeaders(
1538  PHTTPRequest & request // Information on this request.
1539  );
1540 
1549  virtual PString LoadText(
1550  PHTTPRequest & request // Information on this request.
1551  );
1552 
1553  // New functions for class.
1559  const PString & GetString() { return string; }
1560 
1564  const PString & str // New string for the resource.
1565  ) { string = str; }
1566 
1567 
1568  protected:
1570 };
1571 
1572 
1574 // PHTTPFile
1575 
1581 class PHTTPFile : public PHTTPResource
1582 {
1584 
1585  public:
1592  PHTTPFile(
1593  const PString & filename // file in file system and URL name.
1594  );
1595  PHTTPFile(
1596  const PString & filename, // file in file system and URL name.
1597  const PHTTPAuthority & auth // Authorisation for the resource.
1598  );
1599  PHTTPFile(
1600  const PURL & url, // Name of the resource in URL space.
1601  const PFilePath & file // Location of file in file system.
1602  );
1603  PHTTPFile(
1604  const PURL & url, // Name of the resource in URL space.
1605  const PFilePath & file, // Location of file in file system.
1606  const PString & contentType // MIME content type for the file.
1607  );
1608  PHTTPFile(
1609  const PURL & url, // Name of the resource in URL space.
1610  const PFilePath & file, // Location of file in file system.
1611  const PHTTPAuthority & auth // Authorisation for the resource.
1612  );
1613  PHTTPFile(
1614  const PURL & url, // Name of the resource in URL space.
1615  const PFilePath & file, // Location of file in file system.
1616  const PString & contentType, // MIME content type for the file.
1617  const PHTTPAuthority & auth // Authorisation for the resource.
1618  );
1619 
1620 
1621  // Overrides from class PHTTPResource
1627  virtual PHTTPRequest * CreateRequest(
1628  const PURL & url, // Universal Resource Locator for document.
1629  const PMIMEInfo & inMIME, // Extra MIME information in command.
1630  const PMultiPartList & multipartFormInfo,
1631  PHTTPServer & socket
1632  );
1633 
1641  virtual PBoolean LoadHeaders(
1642  PHTTPRequest & request // Information on this request.
1643  );
1644 
1650  virtual PBoolean LoadData(
1651  PHTTPRequest & request, // Information on this request.
1652  PCharArray & data // Data used in reply.
1653  );
1654 
1663  virtual PString LoadText(
1664  PHTTPRequest & request // Information on this request.
1665  );
1666 
1667 
1668  protected:
1669  PHTTPFile(
1670  const PURL & url, // Name of the resource in URL space.
1671  int dummy
1672  );
1673  // Constructor used by PHTTPDirectory
1674 
1675 
1677 };
1678 
1679 
1681 {
1683  public:
1685  const PURL & url, // Universal Resource Locator for document.
1686  const PMIMEInfo & inMIME, // Extra MIME information in command.
1688  PHTTPResource * resource,
1690  );
1691 
1693 };
1694 
1695 
1697 // PHTTPTailFile
1698 
1707 class PHTTPTailFile : public PHTTPFile
1708 {
1710 
1711  public:
1718  PHTTPTailFile(
1719  const PString & filename // file in file system and URL name.
1720  );
1721  PHTTPTailFile(
1722  const PString & filename, // file in file system and URL name.
1723  const PHTTPAuthority & auth // Authorisation for the resource.
1724  );
1725  PHTTPTailFile(
1726  const PURL & url, // Name of the resource in URL space.
1727  const PFilePath & file // Location of file in file system.
1728  );
1729  PHTTPTailFile(
1730  const PURL & url, // Name of the resource in URL space.
1731  const PFilePath & file, // Location of file in file system.
1732  const PString & contentType // MIME content type for the file.
1733  );
1734  PHTTPTailFile(
1735  const PURL & url, // Name of the resource in URL space.
1736  const PFilePath & file, // Location of file in file system.
1737  const PHTTPAuthority & auth // Authorisation for the resource.
1738  );
1739  PHTTPTailFile(
1740  const PURL & url, // Name of the resource in URL space.
1741  const PFilePath & file, // Location of file in file system.
1742  const PString & contentType, // MIME content type for the file.
1743  const PHTTPAuthority & auth // Authorisation for the resource.
1744  );
1745 
1746 
1747  // Overrides from class PHTTPResource
1755  virtual PBoolean LoadHeaders(
1756  PHTTPRequest & request // Information on this request.
1757  );
1758 
1764  virtual PBoolean LoadData(
1765  PHTTPRequest & request, // Information on this request.
1766  PCharArray & data // Data used in reply.
1767  );
1768 };
1769 
1770 
1772 // PHTTPDirectory
1773 
1787 {
1789 
1790  public:
1792  const PURL & url,
1793  const PDirectory & dir
1794  );
1796  const PURL & url,
1797  const PDirectory & dir,
1798  const PHTTPAuthority & auth
1799  );
1800  // Construct a new directory resource for HTTP.
1801 
1802 
1803  // Overrides from class PHTTPResource
1809  virtual PHTTPRequest * CreateRequest(
1810  const PURL & url, // Universal Resource Locator for document.
1811  const PMIMEInfo & inMIME, // Extra MIME information in command.
1812  const PMultiPartList & multipartFormInfo,
1813  PHTTPServer & socket
1814  );
1815 
1823  virtual PBoolean LoadHeaders(
1824  PHTTPRequest & request
1825  );
1826 
1835  virtual PString LoadText(
1836  PHTTPRequest & request
1837  );
1838 
1847  void EnableAuthorisation(const PString & realm);
1848 
1851  void AllowDirectories(PBoolean enable = true);
1852 
1853  protected:
1855  PHTTPServer & server, // Server to send response to.
1856  const PHTTPRequest & request, // Information on this request.
1857  const PHTTPConnectionInfo & conInfo // Information on the connection
1858  );
1859 
1860  PBoolean FindAuthorisations(const PDirectory & dir, PString & realm, PStringToString & authorisations);
1861 
1865 };
1866 
1867 
1869 {
1871  public:
1873  const PURL & url, // Universal Resource Locator for document.
1874  const PMIMEInfo & inMIME, // Extra MIME information in command.
1876  PHTTPResource * resource,
1878  );
1879 
1882 };
1883 
1884 
1885 PFACTORY_LOAD(PURL_HttpLoader);
1886 
1887 
1888 #endif // P_HTTP
1889 
1890 #endif // PTLIB_HTTP_H
1891 
1892 
1893 // End Of File ///////////////////////////////////////////////////////////////