HTTPSTestServer.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // HTTPSTestServer.h
  3. //
  4. // Definition of the HTTPSTestServer class.
  5. //
  6. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
  7. // and Contributors.
  8. //
  9. // SPDX-License-Identifier: BSL-1.0
  10. //
  11. #ifndef HTTPSTestServer_INCLUDED
  12. #define HTTPSTestServer_INCLUDED
  13. #include "Poco/Net/Net.h"
  14. #include "Poco/Net/SecureServerSocket.h"
  15. #include "Poco/Thread.h"
  16. #include "Poco/Event.h"
  17. class HTTPSTestServer: public Poco::Runnable
  18. /// A simple sequential echo server.
  19. {
  20. public:
  21. HTTPSTestServer();
  22. /// Creates the HTTPSTestServer.
  23. explicit HTTPSTestServer(Poco::Net::Context::Ptr pContext);
  24. /// Creates the HTTPSTestServer using the given Context.
  25. ~HTTPSTestServer();
  26. /// Destroys the HTTPSTestServer.
  27. Poco::UInt16 port() const;
  28. /// Returns the port the echo server is
  29. /// listening on.
  30. void run();
  31. /// Does the work.
  32. const std::string& lastRequest() const;
  33. /// Returns the last request.
  34. static const std::string SMALL_BODY;
  35. static const std::string LARGE_BODY;
  36. protected:
  37. bool requestComplete() const;
  38. std::string handleRequest() const;
  39. private:
  40. Poco::Net::SecureServerSocket _socket;
  41. Poco::Thread _thread;
  42. Poco::Event _ready;
  43. std::atomic<bool> _stop;
  44. std::string _lastRequest;
  45. };
  46. #endif // HTTPSTestServer_INCLUDED