| 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 | |
| 12 | |
| 13 | #ifndef HTTPSTestServer_INCLUDED |
| 14 | #define HTTPSTestServer_INCLUDED |
| 15 | |
| 16 | |
| 17 | #include "Poco/Net/Net.h" |
| 18 | #include "Poco/Net/SecureServerSocket.h" |
| 19 | #include "Poco/Thread.h" |
| 20 | #include "Poco/Event.h" |
| 21 | |
| 22 | |
| 23 | class HTTPSTestServer: public Poco::Runnable |
| 24 | /// A simple sequential echo server. |
| 25 | { |
| 26 | public: |
| 27 | HTTPSTestServer(); |
| 28 | /// Creates the HTTPSTestServer. |
| 29 | |
| 30 | explicit HTTPSTestServer(Poco::Net::Context::Ptr pContext); |
| 31 | /// Creates the HTTPSTestServer using the given Context. |
| 32 | |
| 33 | ~HTTPSTestServer(); |
| 34 | /// Destroys the HTTPSTestServer. |
| 35 | |
| 36 | Poco::UInt16 port() const; |
| 37 | /// Returns the port the echo server is |
| 38 | /// listening on. |
| 39 | |
| 40 | void run(); |
| 41 | /// Does the work. |
| 42 | |
| 43 | const std::string& lastRequest() const; |
| 44 | /// Returns the last request. |
| 45 | |
| 46 | static const std::string SMALL_BODY; |
| 47 | static const std::string LARGE_BODY; |
| 48 | |
| 49 | protected: |
| 50 | bool requestComplete() const; |
| 51 | std::string handleRequest() const; |
| 52 | |
| 53 | private: |
| 54 | Poco::Net::SecureServerSocket _socket; |
| 55 | Poco::Thread _thread; |
| 56 | Poco::Event _ready; |
| 57 | bool _stop; |
| 58 | std::string _lastRequest; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | #endif // HTTPSTestServer_INCLUDED |
| 63 | |