mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-16 06:56:41 +02:00
porting 1.4.4 rev. 1968 (fixed SF# 3559665, etc.)
This commit is contained in:
parent
dbda035719
commit
2a6d58c7f2
@ -190,7 +190,6 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
_pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
|
_pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
|
||||||
n = static_cast<int>(_pIstr->gcount());
|
n = static_cast<int>(_pIstr->gcount());
|
||||||
}
|
}
|
||||||
if (n == 0) return 0;
|
|
||||||
_zstr.next_in = (unsigned char*) _buffer;
|
_zstr.next_in = (unsigned char*) _buffer;
|
||||||
_zstr.avail_in = n;
|
_zstr.avail_in = n;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,9 @@
|
|||||||
#include "CppUnit/TestSuite.h"
|
#include "CppUnit/TestSuite.h"
|
||||||
#include "Poco/InflatingStream.h"
|
#include "Poco/InflatingStream.h"
|
||||||
#include "Poco/DeflatingStream.h"
|
#include "Poco/DeflatingStream.h"
|
||||||
|
#include "Poco/MemoryStream.h"
|
||||||
#include "Poco/StreamCopier.h"
|
#include "Poco/StreamCopier.h"
|
||||||
|
#include "Poco/Buffer.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
@ -113,6 +115,22 @@ void ZLibTest::testDeflate3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ZLibTest::testDeflate4()
|
||||||
|
{
|
||||||
|
Poco::Buffer<char> buffer(1024);
|
||||||
|
Poco::MemoryOutputStream ostr(buffer.begin(), static_cast<std::streamsize>(buffer.size()));
|
||||||
|
DeflatingOutputStream deflater(ostr, -10, Z_BEST_SPEED);
|
||||||
|
std::string data(36828, 'x');
|
||||||
|
deflater << data;
|
||||||
|
deflater.close();
|
||||||
|
Poco::MemoryInputStream istr(buffer.begin(), ostr.charsWritten());
|
||||||
|
InflatingInputStream inflater(istr, -10);
|
||||||
|
std::string data2;
|
||||||
|
inflater >> data2;
|
||||||
|
assert (data2 == data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ZLibTest::testGzip1()
|
void ZLibTest::testGzip1()
|
||||||
{
|
{
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
@ -196,6 +214,7 @@ CppUnit::Test* ZLibTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ZLibTest, testDeflate1);
|
CppUnit_addTest(pSuite, ZLibTest, testDeflate1);
|
||||||
CppUnit_addTest(pSuite, ZLibTest, testDeflate2);
|
CppUnit_addTest(pSuite, ZLibTest, testDeflate2);
|
||||||
CppUnit_addTest(pSuite, ZLibTest, testDeflate3);
|
CppUnit_addTest(pSuite, ZLibTest, testDeflate3);
|
||||||
|
CppUnit_addTest(pSuite, ZLibTest, testDeflate4);
|
||||||
CppUnit_addTest(pSuite, ZLibTest, testGzip1);
|
CppUnit_addTest(pSuite, ZLibTest, testGzip1);
|
||||||
CppUnit_addTest(pSuite, ZLibTest, testGzip2);
|
CppUnit_addTest(pSuite, ZLibTest, testGzip2);
|
||||||
CppUnit_addTest(pSuite, ZLibTest, testGzip3);
|
CppUnit_addTest(pSuite, ZLibTest, testGzip3);
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
void testDeflate1();
|
void testDeflate1();
|
||||||
void testDeflate2();
|
void testDeflate2();
|
||||||
void testDeflate3();
|
void testDeflate3();
|
||||||
|
void testDeflate4();
|
||||||
void testGzip1();
|
void testGzip1();
|
||||||
void testGzip2();
|
void testGzip2();
|
||||||
void testGzip3();
|
void testGzip3();
|
||||||
|
@ -231,12 +231,12 @@ void SecureSocketImpl::listen(int backlog)
|
|||||||
void SecureSocketImpl::shutdown()
|
void SecureSocketImpl::shutdown()
|
||||||
{
|
{
|
||||||
if (_pSSL)
|
if (_pSSL)
|
||||||
{
|
{
|
||||||
// Don't shut down the socket more than once.
|
// Don't shut down the socket more than once.
|
||||||
int shutdownState = SSL_get_shutdown(_pSSL);
|
int shutdownState = SSL_get_shutdown(_pSSL);
|
||||||
bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
|
bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
|
||||||
if (!shutdownSent)
|
if (!shutdownSent)
|
||||||
{
|
{
|
||||||
// A proper clean shutdown would require us to
|
// A proper clean shutdown would require us to
|
||||||
// retry the shutdown if we get a zero return
|
// retry the shutdown if we get a zero return
|
||||||
// value, until SSL_shutdown() returns 1.
|
// value, until SSL_shutdown() returns 1.
|
||||||
@ -254,7 +254,7 @@ void SecureSocketImpl::shutdown()
|
|||||||
|
|
||||||
void SecureSocketImpl::close()
|
void SecureSocketImpl::close()
|
||||||
{
|
{
|
||||||
shutdown();
|
try { shutdown(); } catch (...) { }
|
||||||
_pSocket->close();
|
_pSocket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user