diff options
| author | orivej <[email protected]> | 2022-02-10 16:44:49 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:44:49 +0300 |
| commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
| tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/poco/Net/src/HTTPStream.cpp | |
| parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/poco/Net/src/HTTPStream.cpp')
| -rw-r--r-- | contrib/libs/poco/Net/src/HTTPStream.cpp | 346 |
1 files changed, 173 insertions, 173 deletions
diff --git a/contrib/libs/poco/Net/src/HTTPStream.cpp b/contrib/libs/poco/Net/src/HTTPStream.cpp index 2faeb422b03..67e76945c40 100644 --- a/contrib/libs/poco/Net/src/HTTPStream.cpp +++ b/contrib/libs/poco/Net/src/HTTPStream.cpp @@ -1,173 +1,173 @@ -// -// HTTPStream.cpp -// -// Library: Net -// Package: HTTP -// Module: HTTPStream -// -// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Net/HTTPStream.h" -#include "Poco/Net/HTTPSession.h" - - -namespace Poco { -namespace Net { - - -// -// HTTPStreamBuf -// - - -HTTPStreamBuf::HTTPStreamBuf(HTTPSession& session, openmode mode): - HTTPBasicStreamBuf(HTTPBufferAllocator::BUFFER_SIZE, mode), - _session(session), - _mode(mode) -{ -} - - -HTTPStreamBuf::~HTTPStreamBuf() -{ -} - - -void HTTPStreamBuf::close() -{ - if (_mode & std::ios::out) - { - sync(); - if (!_session.getKeepAlive()) - _session.socket().shutdownSend(); - } -} - - -int HTTPStreamBuf::readFromDevice(char* buffer, std::streamsize length) -{ - return _session.read(buffer, length); -} - - -int HTTPStreamBuf::writeToDevice(const char* buffer, std::streamsize length) -{ - - return _session.write(buffer, length); -} - - -// -// HTTPIOS -// - - -HTTPIOS::HTTPIOS(HTTPSession& session, HTTPStreamBuf::openmode mode): - _buf(session, mode) -{ - poco_ios_init(&_buf); -} - - -HTTPIOS::~HTTPIOS() -{ - try - { - _buf.close(); - } - catch (...) - { - } -} - - -HTTPStreamBuf* HTTPIOS::rdbuf() -{ - return &_buf; -} - - -// -// HTTPInputStream -// - - -Poco::MemoryPool HTTPInputStream::_pool(sizeof(HTTPInputStream)); - - -HTTPInputStream::HTTPInputStream(HTTPSession& session): - HTTPIOS(session, std::ios::in), - std::istream(&_buf) -{ -} - - -HTTPInputStream::~HTTPInputStream() -{ -} - - -void* HTTPInputStream::operator new(std::size_t /*size*/) -{ - return _pool.get(); -} - - -void HTTPInputStream::operator delete(void* ptr) -{ - try - { - _pool.release(ptr); - } - catch (...) - { - poco_unexpected(); - } -} - - -// -// HTTPOutputStream -// - - -Poco::MemoryPool HTTPOutputStream::_pool(sizeof(HTTPOutputStream)); - - -HTTPOutputStream::HTTPOutputStream(HTTPSession& session): - HTTPIOS(session, std::ios::out), - std::ostream(&_buf) -{ -} - - -HTTPOutputStream::~HTTPOutputStream() -{ -} - - -void* HTTPOutputStream::operator new(std::size_t /*size*/) -{ - return _pool.get(); -} - - -void HTTPOutputStream::operator delete(void* ptr) -{ - try - { - _pool.release(ptr); - } - catch (...) - { - poco_unexpected(); - } -} - - -} } // namespace Poco::Net +// +// HTTPStream.cpp +// +// Library: Net +// Package: HTTP +// Module: HTTPStream +// +// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/Net/HTTPStream.h" +#include "Poco/Net/HTTPSession.h" + + +namespace Poco { +namespace Net { + + +// +// HTTPStreamBuf +// + + +HTTPStreamBuf::HTTPStreamBuf(HTTPSession& session, openmode mode): + HTTPBasicStreamBuf(HTTPBufferAllocator::BUFFER_SIZE, mode), + _session(session), + _mode(mode) +{ +} + + +HTTPStreamBuf::~HTTPStreamBuf() +{ +} + + +void HTTPStreamBuf::close() +{ + if (_mode & std::ios::out) + { + sync(); + if (!_session.getKeepAlive()) + _session.socket().shutdownSend(); + } +} + + +int HTTPStreamBuf::readFromDevice(char* buffer, std::streamsize length) +{ + return _session.read(buffer, length); +} + + +int HTTPStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +{ + + return _session.write(buffer, length); +} + + +// +// HTTPIOS +// + + +HTTPIOS::HTTPIOS(HTTPSession& session, HTTPStreamBuf::openmode mode): + _buf(session, mode) +{ + poco_ios_init(&_buf); +} + + +HTTPIOS::~HTTPIOS() +{ + try + { + _buf.close(); + } + catch (...) + { + } +} + + +HTTPStreamBuf* HTTPIOS::rdbuf() +{ + return &_buf; +} + + +// +// HTTPInputStream +// + + +Poco::MemoryPool HTTPInputStream::_pool(sizeof(HTTPInputStream)); + + +HTTPInputStream::HTTPInputStream(HTTPSession& session): + HTTPIOS(session, std::ios::in), + std::istream(&_buf) +{ +} + + +HTTPInputStream::~HTTPInputStream() +{ +} + + +void* HTTPInputStream::operator new(std::size_t /*size*/) +{ + return _pool.get(); +} + + +void HTTPInputStream::operator delete(void* ptr) +{ + try + { + _pool.release(ptr); + } + catch (...) + { + poco_unexpected(); + } +} + + +// +// HTTPOutputStream +// + + +Poco::MemoryPool HTTPOutputStream::_pool(sizeof(HTTPOutputStream)); + + +HTTPOutputStream::HTTPOutputStream(HTTPSession& session): + HTTPIOS(session, std::ios::out), + std::ostream(&_buf) +{ +} + + +HTTPOutputStream::~HTTPOutputStream() +{ +} + + +void* HTTPOutputStream::operator new(std::size_t /*size*/) +{ + return _pool.get(); +} + + +void HTTPOutputStream::operator delete(void* ptr) +{ + try + { + _pool.release(ptr); + } + catch (...) + { + poco_unexpected(); + } +} + + +} } // namespace Poco::Net |
