mirror of
https://github.com/pocoproject/poco.git
synced 2026-01-02 02:37:58 +01:00
* reactor http server * fix * test logic * add reactor server session , use buf to cache socket buffer * add reactor example * fix: nodelay, otherwise ack will be after 50 ms * tcp reactor server support multi listener * fix: tcp reactor connection lifetime about socket * feat: add tcp reactor params * format * check http reqeust complete, dynamic size buffer in reactor * remove try catch * remove debug logger * remove debug logger * fix: should not pop in destructor * delete useless * remove cankeepalive temporarily, optimize check complete req * coding style * coding style * reactor server session unit test * http reactor time server add delay param * optimize switch case, and pop completed msg in destructor * refactor reactor server session * fix: check completed request when headers are in lower case like oha, add unit tests * fix auto_ptr compile error, remove logger and coding style * compile and tests fix, add reactor obj in makefile and vcxproj * compile and tests fix in win, add reactor sample vcxproj * compile and tests fix in macos when visibility is hidden
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#ifndef Net_HTTPReactorServerSession_INCLUDED
|
|
#define Net_HTTPReactorServerSession_INCLUDED
|
|
#include "Poco/Net/HTTPServerParams.h"
|
|
#include "Poco/Net/HTTPSession.h"
|
|
#include "Poco/Net/SocketAddress.h"
|
|
#include "Poco/Net/StreamSocket.h"
|
|
#include <cstring>
|
|
#include <string>
|
|
namespace Poco {
|
|
namespace Net {
|
|
|
|
|
|
class Net_API HTTPReactorServerSession : public HTTPSession
|
|
/// This class handles the server side of a
|
|
/// HTTP session. It is used internally by
|
|
/// HTTPReactorServer.
|
|
{
|
|
public:
|
|
HTTPReactorServerSession(const StreamSocket& socket, std::string& buf, HTTPServerParams::Ptr pParams);
|
|
/// Creates the HTTPReactorServerSession.
|
|
|
|
virtual ~HTTPReactorServerSession();
|
|
/// Destroys the HTTPReactorServerSession.
|
|
|
|
SocketAddress clientAddress() override
|
|
{
|
|
return _realsocket.peerAddress();
|
|
}
|
|
/// Returns the client's address.
|
|
|
|
SocketAddress serverAddress() override
|
|
{
|
|
return _realsocket.address();
|
|
}
|
|
/// Returns the server's address.
|
|
|
|
bool checkRequestComplete();
|
|
|
|
void popCompletedRequest();
|
|
|
|
private:
|
|
int get() override;
|
|
|
|
int peek() override;
|
|
|
|
int write(const char* buffer, std::streamsize length) override;
|
|
|
|
bool parseHeaders(std::size_t pos, std::size_t& bodyStart, std::size_t& contentLength, bool& isChunked);
|
|
|
|
bool parseChunkSize(std::size_t& pos, std::size_t& chunkSize, int&);
|
|
|
|
private:
|
|
std::string& _buf;
|
|
char* _pcur;
|
|
char* _pend;
|
|
int _idx;
|
|
int _complete;
|
|
StreamSocket _realsocket;
|
|
};
|
|
|
|
}} // namespace Poco::Net
|
|
|
|
#endif // Net_HTTPReactorServerSession_INCLUDED
|
|
|