ApacheServerRequest.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // ApacheServerRequest.h
  3. //
  4. // Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
  5. // and Contributors.
  6. //
  7. // SPDX-License-Identifier: BSL-1.0
  8. //
  9. #ifndef ApacheConnector_ApacheServerRequest_INCLUDED
  10. #define ApacheConnector_ApacheServerRequest_INCLUDED
  11. #include "ApacheConnector.h"
  12. #include "ApacheStream.h"
  13. #include "Poco/Net/HTTPServerRequest.h"
  14. #include <set>
  15. class ApacheServerResponse;
  16. class ApacheServerRequest: public Poco::Net::HTTPServerRequest
  17. {
  18. public:
  19. ApacheServerRequest(
  20. ApacheRequestRec* pApacheRequest,
  21. const char* serverName,
  22. int serverPort,
  23. const char* clientName,
  24. int clientPort);
  25. /// Creates a new ApacheServerRequest.
  26. ~ApacheServerRequest();
  27. /// Destroys the ApacheServerRequest.
  28. std::istream& stream();
  29. /// Returns the input stream for reading
  30. /// the request body.
  31. ///
  32. /// The stream is valid until the HTTPServerRequest
  33. /// object is destroyed.
  34. bool expectContinue() const;
  35. /// Returns true if the client expects a
  36. /// 100 Continue response.
  37. const Poco::Net::SocketAddress& clientAddress() const;
  38. /// Returns the client's address.
  39. const Poco::Net::SocketAddress& serverAddress() const;
  40. /// Returns the server's address.
  41. const Poco::Net::HTTPServerParams& serverParams() const;
  42. /// Returns a reference to the server parameters.
  43. Poco::Net::HTTPServerResponse& response() const;
  44. /// Returns a reference to the associated response
  45. bool secure() const;
  46. /// Returns true if the request is using a secure
  47. /// connection. Returns false if no secure connection
  48. /// is used, or if it is not known whether a secure
  49. /// connection is used.
  50. protected:
  51. void setResponse(ApacheServerResponse* pResponse);
  52. private:
  53. ApacheRequestRec* _pApacheRequest;
  54. ApacheServerResponse* _pResponse;
  55. ApacheInputStream* _pStream;
  56. Poco::Net::SocketAddress _serverAddress;
  57. Poco::Net::SocketAddress _clientAddress;
  58. friend class ApacheServerResponse;
  59. };
  60. //
  61. // inlines
  62. //
  63. inline std::istream& ApacheServerRequest::stream()
  64. {
  65. poco_check_ptr (_pStream);
  66. return *_pStream;
  67. }
  68. inline const Poco::Net::SocketAddress& ApacheServerRequest::clientAddress() const
  69. {
  70. return _clientAddress;
  71. }
  72. inline const Poco::Net::SocketAddress& ApacheServerRequest::serverAddress() const
  73. {
  74. return _serverAddress;
  75. }
  76. #endif // ApacheConnector_ApacheServerRequest_INCLUDED