mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-27 12:10:49 +00:00
Remove unused code
This commit is contained in:
parent
a3509065b2
commit
91ff08452e
@ -71,23 +71,6 @@ HTMLForm::HTMLForm(const Poco::URI & uri) : field_limit(DFL_FIELD_LIMIT), value_
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::setEncoding(const std::string & encoding_)
|
||||
{
|
||||
encoding = encoding_;
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::addPart(const std::string & name, Poco::Net::PartSource * source)
|
||||
{
|
||||
poco_check_ptr(source);
|
||||
|
||||
Part part;
|
||||
part.name = name;
|
||||
part.source = std::unique_ptr<Poco::Net::PartSource>(source);
|
||||
parts.push_back(std::move(part));
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::load(const Poco::Net::HTTPRequest & request, ReadBuffer & requestBody, PartHandler & handler)
|
||||
{
|
||||
clear();
|
||||
@ -126,36 +109,12 @@ void HTMLForm::load(const Poco::Net::HTTPRequest & request, ReadBuffer & request
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::load(const Poco::Net::HTTPRequest & request)
|
||||
{
|
||||
NullPartHandler nah;
|
||||
EmptyReadBuffer nis;
|
||||
load(request, nis, nah);
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::read(ReadBuffer & in, PartHandler & handler)
|
||||
{
|
||||
if (encoding == ENCODING_URL)
|
||||
readQuery(in);
|
||||
else
|
||||
readMultipart(in, handler);
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::read(ReadBuffer & in)
|
||||
{
|
||||
readQuery(in);
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::read(const std::string & queryString)
|
||||
{
|
||||
ReadBufferFromString istr(queryString);
|
||||
readQuery(istr);
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::readQuery(ReadBuffer & in)
|
||||
{
|
||||
size_t fields = 0;
|
||||
@ -269,22 +228,6 @@ void HTMLForm::readMultipart(ReadBuffer & in_, PartHandler & handler)
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::setFieldLimit(int limit)
|
||||
{
|
||||
poco_assert(limit >= 0);
|
||||
|
||||
field_limit = limit;
|
||||
}
|
||||
|
||||
|
||||
void HTMLForm::setValueLengthLimit(int limit)
|
||||
{
|
||||
poco_assert(limit >= 0);
|
||||
|
||||
value_length_limit = limit;
|
||||
}
|
||||
|
||||
|
||||
HTMLForm::MultipartReadBuffer::MultipartReadBuffer(ReadBuffer & in_, const std::string & boundary_)
|
||||
: ReadBuffer(nullptr, 0), in(in_), boundary("--" + boundary_)
|
||||
{
|
||||
|
@ -52,24 +52,6 @@ public:
|
||||
return (it != end()) ? DB::parse<T>(it->second) : default_value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T getParsed(const std::string & key)
|
||||
{
|
||||
return DB::parse<T>(get(key));
|
||||
}
|
||||
|
||||
/// Sets the encoding used for posting the form.
|
||||
/// Encoding must be either "application/x-www-form-urlencoded" (which is the default) or "multipart/form-data".
|
||||
void setEncoding(const std::string & encoding);
|
||||
|
||||
/// Returns the encoding used for posting the form.
|
||||
const std::string & getEncoding() const { return encoding; }
|
||||
|
||||
/// Adds an part/attachment (file upload) to the form.
|
||||
/// The form takes ownership of the PartSource and deletes it when it is no longer needed.
|
||||
/// The part will only be sent if the encoding set for the form is "multipart/form-data"
|
||||
void addPart(const std::string & name, Poco::Net::PartSource * pSource);
|
||||
|
||||
/// Reads the form data from the given HTTP request.
|
||||
/// Uploaded files are passed to the given PartHandler.
|
||||
void load(const Poco::Net::HTTPRequest & request, ReadBuffer & requestBody, PartHandler & handler);
|
||||
@ -78,41 +60,10 @@ public:
|
||||
/// Uploaded files are silently discarded.
|
||||
void load(const Poco::Net::HTTPRequest & request, ReadBuffer & requestBody);
|
||||
|
||||
/// Reads the form data from the given HTTP request.
|
||||
/// The request must be a GET request and the form data must be in the query string (URL encoded).
|
||||
/// For POST requests, you must use one of the overloads taking an additional input stream for the request body.
|
||||
void load(const Poco::Net::HTTPRequest & request);
|
||||
|
||||
/// Reads the form data from the given input stream.
|
||||
/// The form data read from the stream must be in the encoding specified for the form.
|
||||
/// Note that read() does not clear the form before reading the new values.
|
||||
void read(ReadBuffer & in, PartHandler & handler);
|
||||
|
||||
/// Reads the URL-encoded form data from the given input stream.
|
||||
/// Note that read() does not clear the form before reading the new values.
|
||||
void read(ReadBuffer & in);
|
||||
|
||||
/// Reads the form data from the given HTTP query string.
|
||||
/// Note that read() does not clear the form before reading the new values.
|
||||
void read(const std::string & queryString);
|
||||
|
||||
/// Returns the MIME boundary used for writing multipart form data.
|
||||
const std::string & getBoundary() const { return boundary; }
|
||||
|
||||
/// Returns the maximum number of header fields allowed.
|
||||
/// See setFieldLimit() for more information.
|
||||
int getFieldLimit() const { return field_limit; }
|
||||
|
||||
/// Sets the maximum number of header fields allowed. This limit is used to defend certain kinds of denial-of-service attacks.
|
||||
/// Specify 0 for unlimited (not recommended). The default limit is 100.
|
||||
void setFieldLimit(int limit);
|
||||
|
||||
/// Sets the maximum size for form field values stored as strings.
|
||||
void setValueLengthLimit(int limit);
|
||||
|
||||
/// Returns the maximum size for form field values stored as strings.
|
||||
int getValueLengthLimit() const { return value_length_limit; }
|
||||
|
||||
static const std::string ENCODING_URL; /// "application/x-www-form-urlencoded"
|
||||
static const std::string ENCODING_MULTIPART; /// "multipart/form-data"
|
||||
static const int UNKNOWN_CONTENT_LENGTH;
|
||||
|
@ -98,31 +98,4 @@ void HTTPServerConnection::sendErrorResponse(Poco::Net::HTTPServerSession & sess
|
||||
session.setKeepAlive(false);
|
||||
}
|
||||
|
||||
void HTTPServerConnection::onServerStopped(const bool & abortCurrent)
|
||||
{
|
||||
stopped = true;
|
||||
if (abortCurrent)
|
||||
{
|
||||
try
|
||||
{
|
||||
socket().shutdown();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
|
||||
try
|
||||
{
|
||||
socket().shutdown();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ public:
|
||||
|
||||
protected:
|
||||
static void sendErrorResponse(Poco::Net::HTTPServerSession & session, Poco::Net::HTTPResponse::HTTPStatus status);
|
||||
void onServerStopped(const bool & abortCurrent);
|
||||
|
||||
private:
|
||||
Context context;
|
||||
|
@ -94,32 +94,6 @@ std::pair<std::shared_ptr<std::ostream>, std::shared_ptr<std::ostream>> HTTPServ
|
||||
return std::make_pair(header_stream, stream);
|
||||
}
|
||||
|
||||
void HTTPServerResponse::sendFile(const std::string & path, const std::string & mediaType)
|
||||
{
|
||||
poco_assert(!stream);
|
||||
|
||||
Poco::File f(path);
|
||||
Poco::Timestamp date_time = f.getLastModified();
|
||||
Poco::File::FileSize length = f.getSize();
|
||||
set("Last-Modified", Poco::DateTimeFormatter::format(date_time, Poco::DateTimeFormat::HTTP_FORMAT));
|
||||
setContentLength64(length);
|
||||
setContentType(mediaType);
|
||||
setChunkedTransferEncoding(false);
|
||||
|
||||
Poco::FileInputStream istr(path);
|
||||
if (istr.good())
|
||||
{
|
||||
stream = std::make_shared<Poco::Net::HTTPHeaderOutputStream>(session);
|
||||
write(*stream);
|
||||
if (request && request->getMethod() != HTTPRequest::HTTP_HEAD)
|
||||
{
|
||||
Poco::StreamCopier::copyStream(istr, *stream);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw Poco::OpenFileException(path);
|
||||
}
|
||||
|
||||
void HTTPServerResponse::sendBuffer(const void * buffer, std::size_t length)
|
||||
{
|
||||
poco_assert(!stream);
|
||||
@ -135,20 +109,6 @@ void HTTPServerResponse::sendBuffer(const void * buffer, std::size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
void HTTPServerResponse::redirect(const std::string & uri, HTTPStatus status)
|
||||
{
|
||||
poco_assert(!stream);
|
||||
|
||||
setContentLength(0);
|
||||
setChunkedTransferEncoding(false);
|
||||
|
||||
setStatusAndReason(status);
|
||||
set("Location", uri);
|
||||
|
||||
stream = std::make_shared<Poco::Net::HTTPHeaderOutputStream>(session);
|
||||
write(*stream);
|
||||
}
|
||||
|
||||
void HTTPServerResponse::requireAuthentication(const std::string & realm)
|
||||
{
|
||||
poco_assert(!stream);
|
||||
|
@ -36,17 +36,6 @@ public:
|
||||
/// or redirect() has been called.
|
||||
std::pair<std::shared_ptr<std::ostream>, std::shared_ptr<std::ostream>> beginSend(); /// TODO: use some WriteBuffer implementation here.
|
||||
|
||||
/// Sends the response header to the client, followed
|
||||
/// by the content of the given file.
|
||||
///
|
||||
/// Must not be called after send(), sendBuffer()
|
||||
/// or redirect() has been called.
|
||||
///
|
||||
/// Throws a FileNotFoundException if the file
|
||||
/// cannot be found, or an OpenFileException if
|
||||
/// the file cannot be opened.
|
||||
void sendFile(const std::string & path, const std::string & mediaType);
|
||||
|
||||
/// Sends the response header to the client, followed
|
||||
/// by the contents of the given buffer.
|
||||
///
|
||||
@ -61,16 +50,6 @@ public:
|
||||
/// or redirect() has been called.
|
||||
void sendBuffer(const void * pBuffer, std::size_t length); /// FIXME: do we need this one?
|
||||
|
||||
/// Sets the status code, which must be one of
|
||||
/// HTTP_MOVED_PERMANENTLY (301), HTTP_FOUND (302),
|
||||
/// or HTTP_SEE_OTHER (303),
|
||||
/// and sets the "Location" header field
|
||||
/// to the given URI, which according to
|
||||
/// the HTTP specification, must be absolute.
|
||||
///
|
||||
/// Must not be called after send() has been called.
|
||||
void redirect(const std::string & uri, Poco::Net::HTTPResponse::HTTPStatus status = Poco::Net::HTTPResponse::HTTP_FOUND);
|
||||
|
||||
void requireAuthentication(const std::string & realm);
|
||||
/// Sets the status code to 401 (Unauthorized)
|
||||
/// and sets the "WWW-Authenticate" header field
|
||||
|
Loading…
Reference in New Issue
Block a user