ApacheServerRequest.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. protected:
  46. void setResponse(ApacheServerResponse* pResponse);
  47. private:
  48. ApacheRequestRec* _pApacheRequest;
  49. ApacheServerResponse* _pResponse;
  50. ApacheInputStream* _pStream;
  51. Poco::Net::SocketAddress _serverAddress;
  52. Poco::Net::SocketAddress _clientAddress;
  53. friend class ApacheServerResponse;
  54. };
  55. //
  56. // inlines
  57. //
  58. inline std::istream& ApacheServerRequest::stream()
  59. {
  60. poco_check_ptr (_pStream);
  61. return *_pStream;
  62. }
  63. inline const Poco::Net::SocketAddress& ApacheServerRequest::clientAddress() const
  64. {
  65. return _clientAddress;
  66. }
  67. inline const Poco::Net::SocketAddress& ApacheServerRequest::serverAddress() const
  68. {
  69. return _serverAddress;
  70. }
  71. #endif // ApacheConnector_ApacheServerRequest_INCLUDED