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