diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-14 09:58:56 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-14 10:20:20 +0300 |
commit | c2b2dfd9827a400a8495e172a56343462e3ceb82 (patch) | |
tree | cd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/Server/HTTP/HTTPServerRequest.h | |
parent | d4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff) | |
download | ydb-c2b2dfd9827a400a8495e172a56343462e3ceb82.tar.gz |
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/Server/HTTP/HTTPServerRequest.h')
-rw-r--r-- | contrib/clickhouse/src/Server/HTTP/HTTPServerRequest.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/Server/HTTP/HTTPServerRequest.h b/contrib/clickhouse/src/Server/HTTP/HTTPServerRequest.h new file mode 100644 index 0000000000..da0e498b0d --- /dev/null +++ b/contrib/clickhouse/src/Server/HTTP/HTTPServerRequest.h @@ -0,0 +1,73 @@ +#pragma once + +#include <Interpreters/Context_fwd.h> +#include <IO/ReadBuffer.h> +#include <Server/HTTP/HTTPRequest.h> +#include <Server/HTTP/HTTPContext.h> +#include "clickhouse_config.h" + +#include <Poco/Net/HTTPServerSession.h> + +namespace Poco::Net { class X509Certificate; } + +namespace DB +{ + +class HTTPServerResponse; +class ReadBufferFromPocoSocket; + +class HTTPServerRequest : public HTTPRequest +{ +public: + HTTPServerRequest(HTTPContextPtr context, HTTPServerResponse & response, Poco::Net::HTTPServerSession & session); + + /// FIXME: it's a little bit inconvenient interface. The rationale is that all other ReadBuffer's wrap each other + /// via unique_ptr - but we can't inherit HTTPServerRequest from ReadBuffer and pass it around, + /// since we also need it in other places. + + /// Returns the input stream for reading the request body. + ReadBuffer & getStream() + { + poco_check_ptr(stream); + return *stream; + } + + bool checkPeerConnected() const; + + bool isSecure() const { return secure; } + + /// Returns the client's address. + const Poco::Net::SocketAddress & clientAddress() const { return client_address; } + + /// Returns the server's address. + const Poco::Net::SocketAddress & serverAddress() const { return server_address; } + +#if USE_SSL + bool havePeerCertificate() const; + Poco::Net::X509Certificate peerCertificate() const; +#endif + +private: + /// Limits for basic sanity checks when reading a header + enum Limits + { + MAX_METHOD_LENGTH = 32, + MAX_VERSION_LENGTH = 8, + }; + + const size_t max_uri_size; + const size_t max_fields_number; + const size_t max_field_name_size; + const size_t max_field_value_size; + + std::unique_ptr<ReadBuffer> stream; + Poco::Net::SocketImpl * socket; + Poco::Net::SocketAddress client_address; + Poco::Net::SocketAddress server_address; + + bool secure; + + void readRequest(ReadBuffer & in); +}; + +} |