mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-17 15:14:48 +02:00
commit
4d592f68bf
@ -26,13 +26,13 @@ matrix:
|
||||
- env: TEST_NAME="gcc (make)"
|
||||
compiler: gcc
|
||||
script:
|
||||
- ./configure && make -s -j2
|
||||
- ./configure --everything && make -s -j2
|
||||
- ./travis/runtests.sh
|
||||
|
||||
- env: TEST_NAME="clang (make)"
|
||||
compiler: clang
|
||||
script:
|
||||
- ./configure --config=Linux-clang && make -s -j2
|
||||
- ./configure --everything --config=Linux-clang && make -s -j2
|
||||
- ./travis/runtests.sh
|
||||
|
||||
- env: TEST_NAME="arm-linux-gnueabi- (make)"
|
||||
|
@ -114,6 +114,7 @@ Utility::Utility()
|
||||
_types.insert(TypeMap::value_type("NCLOB", MetaColumn::FDT_STRING));
|
||||
_types.insert(TypeMap::value_type("NTEXT", MetaColumn::FDT_STRING));
|
||||
_types.insert(TypeMap::value_type("NVARCHAR", MetaColumn::FDT_STRING));
|
||||
_types.insert(TypeMap::value_type("LONGVARCHAR", MetaColumn::FDT_STRING));
|
||||
_types.insert(TypeMap::value_type("BLOB", MetaColumn::FDT_BLOB));
|
||||
_types.insert(TypeMap::value_type("DATE", MetaColumn::FDT_DATE));
|
||||
_types.insert(TypeMap::value_type("TIME", MetaColumn::FDT_TIME));
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define Foundation_MemoryStream_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Bugcheck.h"
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/StreamUtil.h"
|
||||
#include <streambuf>
|
||||
@ -84,20 +85,24 @@ public:
|
||||
if (this->gptr() == 0)
|
||||
return fail;
|
||||
|
||||
switch (way)
|
||||
if (way == std::ios_base::beg)
|
||||
{
|
||||
case std::ios_base::beg:
|
||||
newoff = 0;
|
||||
break;
|
||||
case std::ios_base::cur:
|
||||
}
|
||||
else if (way == std::ios_base::cur)
|
||||
{
|
||||
// cur is not valid if both in and out are specified (Condition 3)
|
||||
if ((which & std::ios_base::out) != 0)
|
||||
return fail;
|
||||
newoff = this->gptr() - this->eback();
|
||||
break;
|
||||
case std::ios_base::end:
|
||||
}
|
||||
else if (way == std::ios_base::end)
|
||||
{
|
||||
newoff = this->egptr() - this->eback();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
poco_bugcheck();
|
||||
}
|
||||
|
||||
if ((newoff + off) < 0 || (this->egptr() - this->eback()) < (newoff + off))
|
||||
@ -110,20 +115,24 @@ public:
|
||||
if (this->pptr() == 0)
|
||||
return fail;
|
||||
|
||||
switch (way)
|
||||
if (way == std::ios_base::beg)
|
||||
{
|
||||
case std::ios_base::beg:
|
||||
newoff = 0;
|
||||
break;
|
||||
case std::ios_base::cur:
|
||||
}
|
||||
else if (way == std::ios_base::cur)
|
||||
{
|
||||
// cur is not valid if both in and out are specified (Condition 3)
|
||||
if ((which & std::ios_base::in) != 0)
|
||||
return fail;
|
||||
newoff = this->pptr() - this->pbase();
|
||||
break;
|
||||
case std::ios_base::end:
|
||||
}
|
||||
else if (way == std::ios_base::end)
|
||||
{
|
||||
newoff = this->epptr() - this->pbase();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
poco_bugcheck();
|
||||
}
|
||||
|
||||
if (newoff + off < 0 || (this->epptr() - this->pbase()) < newoff + off)
|
||||
|
@ -297,7 +297,7 @@ void FileImpl::renameToImpl(const std::string& path)
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (MoveFileA(_path.c_str(), path.c_str()) == 0)
|
||||
if (MoveFileExA(_path.c_str(), path.c_str(), MOVEFILE_REPLACE_EXISTING) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ void FileImpl::renameToImpl(const std::string& path)
|
||||
|
||||
std::wstring upath;
|
||||
UnicodeConverter::toUTF16(path, upath);
|
||||
if (MoveFileW(_upath.c_str(), upath.c_str()) == 0)
|
||||
if (MoveFileExW(_upath.c_str(), upath.c_str(), MOVEFILE_REPLACE_EXISTING) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
2
Makefile
2
Makefile
@ -41,7 +41,7 @@ install: libexecs
|
||||
mkdir -p $(INSTALLDIR)/include/Poco
|
||||
mkdir -p $(INSTALLDIR)/lib
|
||||
mkdir -p $(INSTALLDIR)/bin
|
||||
for comp in $(COMPONENTS) ; do \
|
||||
for comp in $(filter-out $(foreach f,$(OMIT),$f%),$(COMPONENTS)) ; do \
|
||||
if [ -d "$(POCO_BASE)/$$comp/include" ] ; then \
|
||||
cp -Rf $(POCO_BASE)/$$comp/include/* $(INSTALLDIR)/include/ ; \
|
||||
fi ; \
|
||||
|
@ -227,6 +227,24 @@ public:
|
||||
/// to ensure a new connection will be set up
|
||||
/// for the next request.
|
||||
|
||||
virtual bool peekResponse(HTTPResponse& response);
|
||||
/// If the request contains a "Expect: 100-continue" header,
|
||||
/// (see HTTPRequest::setExpectContinue()) this method can be
|
||||
/// used to check whether the server has sent a 100 Continue response
|
||||
/// before continuing with the request, i.e. sending the request body,
|
||||
/// after calling sendRequest().
|
||||
///
|
||||
/// Returns true if the server has responded with 100 Continue,
|
||||
/// otherwise false. The HTTPResponse object contains the
|
||||
/// response sent by the server.
|
||||
///
|
||||
/// In any case, receiveResponse() must be called afterwards as well in
|
||||
/// order to complete the request. The same HTTPResponse object
|
||||
/// passed to peekResponse() must also be passed to receiveResponse().
|
||||
///
|
||||
/// This method should only be called if the request contains
|
||||
/// a "Expect: 100-continue" header.
|
||||
|
||||
void reset();
|
||||
/// Resets the session and closes the socket.
|
||||
///
|
||||
@ -291,6 +309,7 @@ private:
|
||||
bool _reconnect;
|
||||
bool _mustReconnect;
|
||||
bool _expectResponseBody;
|
||||
bool _responseReceived;
|
||||
Poco::SharedPtr<std::ostream> _pRequestStream;
|
||||
Poco::SharedPtr<std::istream> _pResponseStream;
|
||||
|
||||
|
@ -104,7 +104,15 @@ public:
|
||||
void setCredentials(const std::string& scheme, const std::string& authInfo);
|
||||
/// Sets the authentication scheme and information for
|
||||
/// this request.
|
||||
|
||||
bool getExpectContinue() const;
|
||||
/// Returns true if the request contains an
|
||||
/// "Expect: 100-continue" header.
|
||||
|
||||
void setExpectContinue(bool expectContinue);
|
||||
/// Adds a "Expect: 100-continue" header to the request if
|
||||
/// expectContinue is true, otherwise removes the Expect header.
|
||||
|
||||
bool hasProxyCredentials() const;
|
||||
/// Returns true iff the request contains proxy authentication
|
||||
/// information in the form of an Proxy-Authorization header.
|
||||
@ -143,6 +151,7 @@ public:
|
||||
static const std::string AUTHORIZATION;
|
||||
static const std::string PROXY_AUTHORIZATION;
|
||||
static const std::string UPGRADE;
|
||||
static const std::string EXPECT;
|
||||
|
||||
protected:
|
||||
void getCredentials(const std::string& header, std::string& scheme, std::string& authInfo) const;
|
||||
|
@ -52,6 +52,15 @@ public:
|
||||
/// Must be overridden by subclasses.
|
||||
///
|
||||
/// Creates a new request handler for the given HTTP request.
|
||||
///
|
||||
/// The method should inspect the given HTTPServerRequest object (e.g., method
|
||||
/// and URI) and create an appropriate HTTPRequestHandler object to handle the
|
||||
/// request.
|
||||
///
|
||||
/// If the request contains a "Expect: 100-continue" header, it's possible
|
||||
/// to prevent the server from sending the default 100 Continue response
|
||||
/// by setting the status of the response object that can be obtained through
|
||||
/// the request object (request.response()) to something other than 200 OK.
|
||||
|
||||
protected:
|
||||
Poco::BasicEvent<const bool> serverStopped;
|
||||
|
@ -56,10 +56,6 @@ public:
|
||||
/// The stream must be valid until the HTTPServerRequest
|
||||
/// object is destroyed.
|
||||
|
||||
virtual bool expectContinue() const = 0;
|
||||
/// Returns true if the client expects a
|
||||
/// 100 Continue response.
|
||||
|
||||
virtual const SocketAddress& clientAddress() const = 0;
|
||||
/// Returns the client's address.
|
||||
|
||||
|
@ -59,10 +59,6 @@ public:
|
||||
/// The stream is valid until the HTTPServerRequestImpl
|
||||
/// object is destroyed.
|
||||
|
||||
bool expectContinue() const;
|
||||
/// Returns true if the client expects a
|
||||
/// 100 Continue response.
|
||||
|
||||
const SocketAddress& clientAddress() const;
|
||||
/// Returns the client's address.
|
||||
|
||||
@ -87,9 +83,6 @@ public:
|
||||
StreamSocket detachSocket();
|
||||
/// Returns the underlying socket after detaching
|
||||
/// it from the server session.
|
||||
|
||||
protected:
|
||||
static const std::string EXPECT;
|
||||
|
||||
private:
|
||||
HTTPServerResponseImpl& _response;
|
||||
|
@ -236,6 +236,9 @@ public:
|
||||
/// The ipVersion argument can be used to specify whether
|
||||
/// an IPv4 (IPv4_ONLY) or IPv6 (IPv6_ONLY) interface is required,
|
||||
/// or whether the caller does not care (IPv4_OR_IPv6).
|
||||
///
|
||||
/// Throws an InterfaceNotFoundException if an interface
|
||||
/// with the give name does not exist.
|
||||
|
||||
static NetworkInterface forAddress(const IPAddress& address);
|
||||
/// Returns the NetworkInterface for the given IP address.
|
||||
@ -247,8 +250,7 @@ public:
|
||||
/// Returns the NetworkInterface for the given interface index.
|
||||
///
|
||||
/// Throws an InterfaceNotFoundException if an interface
|
||||
/// with the given index does not exist (or IPv6 is not
|
||||
/// available).
|
||||
/// with the given index does not exist.
|
||||
|
||||
static List list(bool ipOnly = true, bool upOnly = true);
|
||||
/// Returns a list with all network interfaces
|
||||
|
@ -46,7 +46,8 @@ HTTPClientSession::HTTPClientSession():
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false)
|
||||
_expectResponseBody(false),
|
||||
_responseReceived(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -58,7 +59,8 @@ HTTPClientSession::HTTPClientSession(const StreamSocket& socket):
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false)
|
||||
_expectResponseBody(false),
|
||||
_responseReceived(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -70,7 +72,8 @@ HTTPClientSession::HTTPClientSession(const SocketAddress& address):
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false)
|
||||
_expectResponseBody(false),
|
||||
_responseReceived(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -82,7 +85,8 @@ HTTPClientSession::HTTPClientSession(const std::string& host, Poco::UInt16 port)
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false)
|
||||
_expectResponseBody(false),
|
||||
_responseReceived(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -94,7 +98,8 @@ HTTPClientSession::HTTPClientSession(const std::string& host, Poco::UInt16 port,
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false)
|
||||
_expectResponseBody(false),
|
||||
_responseReceived(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -192,6 +197,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
|
||||
{
|
||||
clearException();
|
||||
_pResponseStream = 0;
|
||||
_responseReceived = false;
|
||||
|
||||
bool keepAlive = getKeepAlive();
|
||||
if (((connected() && !keepAlive) || mustReconnect()) && !_host.empty())
|
||||
@ -259,25 +265,28 @@ std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
|
||||
_pRequestStream = 0;
|
||||
if (networkException()) networkException()->rethrow();
|
||||
|
||||
do
|
||||
if (!_responseReceived)
|
||||
{
|
||||
response.clear();
|
||||
HTTPHeaderInputStream his(*this);
|
||||
try
|
||||
do
|
||||
{
|
||||
response.read(his);
|
||||
}
|
||||
catch (Exception&)
|
||||
{
|
||||
close();
|
||||
if (networkException())
|
||||
networkException()->rethrow();
|
||||
else
|
||||
response.clear();
|
||||
HTTPHeaderInputStream his(*this);
|
||||
try
|
||||
{
|
||||
response.read(his);
|
||||
}
|
||||
catch (Exception&)
|
||||
{
|
||||
close();
|
||||
if (networkException())
|
||||
networkException()->rethrow();
|
||||
else
|
||||
throw;
|
||||
throw;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
while (response.getStatus() == HTTPResponse::HTTP_CONTINUE);
|
||||
}
|
||||
while (response.getStatus() == HTTPResponse::HTTP_CONTINUE);
|
||||
|
||||
_mustReconnect = getKeepAlive() && !response.getKeepAlive();
|
||||
|
||||
@ -298,6 +307,34 @@ std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
|
||||
}
|
||||
|
||||
|
||||
bool HTTPClientSession::peekResponse(HTTPResponse& response)
|
||||
{
|
||||
poco_assert (!_responseReceived);
|
||||
|
||||
_pRequestStream->flush();
|
||||
|
||||
if (networkException()) networkException()->rethrow();
|
||||
|
||||
response.clear();
|
||||
HTTPHeaderInputStream his(*this);
|
||||
try
|
||||
{
|
||||
response.read(his);
|
||||
}
|
||||
catch (Exception&)
|
||||
{
|
||||
close();
|
||||
if (networkException())
|
||||
networkException()->rethrow();
|
||||
else
|
||||
throw;
|
||||
throw;
|
||||
}
|
||||
_responseReceived = response.getStatus() != HTTPResponse::HTTP_CONTINUE;
|
||||
return !_responseReceived;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::reset()
|
||||
{
|
||||
close();
|
||||
|
@ -43,6 +43,7 @@ const std::string HTTPRequest::COOKIE = "Cookie";
|
||||
const std::string HTTPRequest::AUTHORIZATION = "Authorization";
|
||||
const std::string HTTPRequest::PROXY_AUTHORIZATION = "Proxy-Authorization";
|
||||
const std::string HTTPRequest::UPGRADE = "Upgrade";
|
||||
const std::string HTTPRequest::EXPECT = "Expect";
|
||||
|
||||
|
||||
HTTPRequest::HTTPRequest():
|
||||
@ -259,4 +260,20 @@ void HTTPRequest::setCredentials(const std::string& header, const std::string& s
|
||||
}
|
||||
|
||||
|
||||
bool HTTPRequest::getExpectContinue() const
|
||||
{
|
||||
const std::string& expect = get(EXPECT, EMPTY);
|
||||
return !expect.empty() && icompare(expect, "100-continue") == 0;
|
||||
}
|
||||
|
||||
|
||||
void HTTPRequest::setExpectContinue(bool expectContinue)
|
||||
{
|
||||
if (expectContinue)
|
||||
set(EXPECT, "100-continue");
|
||||
else
|
||||
erase(EXPECT);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
@ -81,7 +81,7 @@ void HTTPServerConnection::run()
|
||||
std::auto_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
|
||||
if (pHandler.get())
|
||||
{
|
||||
if (request.expectContinue())
|
||||
if (request.getExpectContinue() && response.getStatus() == HTTPResponse::HTTP_OK)
|
||||
response.sendContinue();
|
||||
|
||||
pHandler->handleRequest(request, response);
|
||||
|
@ -33,9 +33,6 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
const std::string HTTPServerRequestImpl::EXPECT("Expect");
|
||||
|
||||
|
||||
HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponseImpl& response, HTTPServerSession& session, HTTPServerParams* pParams):
|
||||
_response(response),
|
||||
_session(session),
|
||||
@ -90,11 +87,4 @@ StreamSocket HTTPServerRequestImpl::detachSocket()
|
||||
}
|
||||
|
||||
|
||||
bool HTTPServerRequestImpl::expectContinue() const
|
||||
{
|
||||
const std::string& expect = get(EXPECT, EMPTY);
|
||||
return !expect.empty() && icompare(expect, "100-continue") == 0;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
@ -794,16 +794,8 @@ bool NetworkInterface::isUp() const
|
||||
|
||||
NetworkInterface NetworkInterface::forName(const std::string& name, bool requireIPv6)
|
||||
{
|
||||
Map map = NetworkInterface::map(false, false);
|
||||
Map::const_iterator it = map.begin();
|
||||
Map::const_iterator end = map.end();
|
||||
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
if (it->second.name() == name && ((requireIPv6 && it->second.supportsIPv6()) || !requireIPv6))
|
||||
return it->second;
|
||||
}
|
||||
throw InterfaceNotFoundException(name);
|
||||
if (requireIPv6) return forName(name, IPv6_ONLY);
|
||||
else return forName(name, IPv4_OR_IPv6);
|
||||
}
|
||||
|
||||
|
||||
@ -881,7 +873,7 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
|
||||
const List& ipList = it->second.addressList();
|
||||
List::const_iterator ipIt = ipList.begin();
|
||||
List::const_iterator ipEnd = ipList.end();
|
||||
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
|
||||
for (; ipIt != ipEnd; ++ipIt)
|
||||
{
|
||||
IPAddress addr = ipIt->get<NetworkInterface::IP_ADDRESS>();
|
||||
IPAddress mask = ipIt->get<NetworkInterface::SUBNET_MASK>();
|
||||
|
@ -300,6 +300,47 @@ void HTTPClientSessionTest::testBypassProxy()
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSessionTest::testExpectContinue()
|
||||
{
|
||||
HTTPTestServer srv;
|
||||
HTTPClientSession s("localhost", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_POST, "/expect");
|
||||
std::string body("this is a random request body\r\n0\r\n");
|
||||
request.setContentLength((int) body.length());
|
||||
request.setExpectContinue(true);
|
||||
s.sendRequest(request) << body;
|
||||
HTTPResponse response;
|
||||
assert (s.peekResponse(response));
|
||||
assert (response.getStatus() == HTTPResponse::HTTP_CONTINUE);
|
||||
std::istream& rs = s.receiveResponse(response);
|
||||
assert (response.getStatus() == HTTPResponse::HTTP_OK);
|
||||
assert (response.getContentLength() == body.length());
|
||||
std::ostringstream ostr;
|
||||
StreamCopier::copyStream(rs, ostr);
|
||||
assert (ostr.str() == body);
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSessionTest::testExpectContinueFail()
|
||||
{
|
||||
HTTPTestServer srv;
|
||||
HTTPClientSession s("localhost", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_POST, "/fail");
|
||||
std::string body("this is a random request body\r\n0\r\n");
|
||||
request.setContentLength((int) body.length());
|
||||
request.setExpectContinue(true);
|
||||
s.sendRequest(request) << body;
|
||||
HTTPResponse response;
|
||||
assert (!s.peekResponse(response));
|
||||
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);
|
||||
std::istream& rs = s.receiveResponse(response);
|
||||
assert (response.getStatus() == HTTPResponse::HTTP_BAD_REQUEST);
|
||||
std::ostringstream ostr;
|
||||
StreamCopier::copyStream(rs, ostr);
|
||||
assert (ostr.str().empty());
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSessionTest::setUp()
|
||||
{
|
||||
}
|
||||
@ -327,6 +368,8 @@ CppUnit::Test* HTTPClientSessionTest::suite()
|
||||
CppUnit_addTest(pSuite, HTTPClientSessionTest, testProxy);
|
||||
CppUnit_addTest(pSuite, HTTPClientSessionTest, testProxyAuth);
|
||||
CppUnit_addTest(pSuite, HTTPClientSessionTest, testBypassProxy);
|
||||
CppUnit_addTest(pSuite, HTTPClientSessionTest, testExpectContinue);
|
||||
CppUnit_addTest(pSuite, HTTPClientSessionTest, testExpectContinueFail);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
void testProxy();
|
||||
void testProxyAuth();
|
||||
void testBypassProxy();
|
||||
void testExpectContinue();
|
||||
void testExpectContinueFail();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -142,6 +142,37 @@ std::string HTTPTestServer::handleRequest() const
|
||||
if (_lastRequest.substr(0, 3) == "GET")
|
||||
response.append(body);
|
||||
}
|
||||
else if (_lastRequest.substr(0, 12) == "POST /expect")
|
||||
{
|
||||
std::string::size_type pos = _lastRequest.find("\r\n\r\n");
|
||||
pos += 4;
|
||||
std::string body = _lastRequest.substr(pos);
|
||||
response.append("HTTP/1.1 100 Continue\r\n\r\n");
|
||||
response.append("HTTP/1.1 200 OK\r\n");
|
||||
response.append("Content-Type: text/plain\r\n");
|
||||
if (_lastRequest.find("Content-Length") != std::string::npos)
|
||||
{
|
||||
response.append("Content-Length: ");
|
||||
response.append(NumberFormatter::format((int) body.size()));
|
||||
response.append("\r\n");
|
||||
}
|
||||
else if (_lastRequest.find("chunked") != std::string::npos)
|
||||
{
|
||||
response.append("Transfer-Encoding: chunked\r\n");
|
||||
}
|
||||
response.append("Connection: Close\r\n");
|
||||
response.append("\r\n");
|
||||
response.append(body);
|
||||
}
|
||||
else if (_lastRequest.substr(0, 10) == "POST /fail")
|
||||
{
|
||||
std::string::size_type pos = _lastRequest.find("\r\n\r\n");
|
||||
pos += 4;
|
||||
std::string body = _lastRequest.substr(pos);
|
||||
response.append("HTTP/1.1 400 Bad Request\r\n");
|
||||
response.append("Connection: Close\r\n");
|
||||
response.append("\r\n");
|
||||
}
|
||||
else if (_lastRequest.substr(0, 4) == "POST")
|
||||
{
|
||||
std::string::size_type pos = _lastRequest.find("\r\n\r\n");
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "Poco/Net/Context.h"
|
||||
#include "Poco/Net/Utility.h"
|
||||
#include "Poco/Net/PrivateKeyPassphraseHandler.h"
|
||||
#include "Poco/Net/RejectCertificateHandler.h"
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include "Poco/Net/SSLException.h"
|
||||
#include "Poco/SingletonHolder.h"
|
||||
@ -34,11 +35,11 @@ const std::string SSLManager::CFG_PRIV_KEY_FILE("privateKeyFile");
|
||||
const std::string SSLManager::CFG_CERTIFICATE_FILE("certificateFile");
|
||||
const std::string SSLManager::CFG_CA_LOCATION("caConfig");
|
||||
const std::string SSLManager::CFG_VER_MODE("verificationMode");
|
||||
const Context::VerificationMode SSLManager::VAL_VER_MODE(Context::VERIFY_STRICT);
|
||||
const Context::VerificationMode SSLManager::VAL_VER_MODE(Context::VERIFY_RELAXED);
|
||||
const std::string SSLManager::CFG_VER_DEPTH("verificationDepth");
|
||||
const int SSLManager::VAL_VER_DEPTH(9);
|
||||
const std::string SSLManager::CFG_ENABLE_DEFAULT_CA("loadDefaultCAFile");
|
||||
const bool SSLManager::VAL_ENABLE_DEFAULT_CA(false);
|
||||
const bool SSLManager::VAL_ENABLE_DEFAULT_CA(true);
|
||||
const std::string SSLManager::CFG_CIPHER_LIST("cipherList");
|
||||
const std::string SSLManager::CFG_CYPHER_LIST("cypherList");
|
||||
const std::string SSLManager::VAL_CIPHER_LIST("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
@ -134,8 +135,18 @@ Context::Ptr SSLManager::defaultClientContext()
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (!_ptrDefaultClientContext)
|
||||
initDefaultContext(false);
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
initDefaultContext(false);
|
||||
}
|
||||
catch (Poco::IllegalStateException&)
|
||||
{
|
||||
_ptrClientCertificateHandler = new RejectCertificateHandler(false);
|
||||
_ptrDefaultClientContext = new Context(Context::TLSV1_CLIENT_USE, "", Context::VERIFY_RELAXED, 9, true);
|
||||
}
|
||||
}
|
||||
|
||||
return _ptrDefaultClientContext;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,8 @@ private:
|
||||
/// Stores directory info for all found disks
|
||||
DirectoryInfos64 _disks64;
|
||||
/// Stores directory info for all found disks
|
||||
|
||||
static const std::string EMPTY_COMMENT;
|
||||
|
||||
friend class Compress;
|
||||
};
|
||||
|
@ -24,6 +24,9 @@ namespace Poco {
|
||||
namespace Zip {
|
||||
|
||||
|
||||
const std::string ZipArchive::EMPTY_COMMENT;
|
||||
|
||||
|
||||
ZipArchive::ZipArchive(std::istream& in):
|
||||
_entries(),
|
||||
_infos(),
|
||||
@ -110,7 +113,18 @@ const std::string& ZipArchive::getZipComment() const
|
||||
{
|
||||
// It seems that only the "first" disk is populated (look at Compress::close()), so getting the first ZipArchiveInfo
|
||||
DirectoryInfos::const_iterator it = _disks.begin();
|
||||
return it->second.getZipComment();
|
||||
if (it != _disks.end())
|
||||
{
|
||||
return it->second.getZipComment();
|
||||
}
|
||||
else
|
||||
{
|
||||
DirectoryInfos64::const_iterator it64 = _disks64.begin();
|
||||
if (it64 != _disks64.end())
|
||||
return it->second.getZipComment();
|
||||
else
|
||||
return EMPTY_COMMENT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,6 +55,9 @@ ZipFileInfo::ZipFileInfo(const ZipLocalFileHeader& header):
|
||||
setUnixAttributes();
|
||||
|
||||
_rawInfo[GENERAL_PURPOSE_POS+1] |= 0x08; // Set "language encoding flag" to indicate that filenames and paths are in UTF-8.
|
||||
|
||||
if (header.searchCRCAndSizesAfterData())
|
||||
_rawInfo[GENERAL_PURPOSE_POS] |= 0x08;
|
||||
}
|
||||
|
||||
|
||||
|
@ -218,6 +218,12 @@ void ZipStreamBuf::close(Poco::UInt64& extraDataSize)
|
||||
poco_assert (*_pOstr);
|
||||
// write an extra datablock if required
|
||||
// or fix the crc entries
|
||||
poco_check_ptr(_pHeader);
|
||||
_pHeader->setCRC(_crc32.checksum());
|
||||
_pHeader->setUncompressedSize(_bytesWritten);
|
||||
_pHeader->setCompressedSize(_ptrOHelper->bytesWritten());
|
||||
_pHeader->setStartPos(_pHeader->getStartPos()); // This resets EndPos now that compressed Size is known
|
||||
|
||||
if (_pHeader->searchCRCAndSizesAfterData())
|
||||
{
|
||||
if (_pHeader->needsZip64())
|
||||
@ -241,13 +247,8 @@ void ZipStreamBuf::close(Poco::UInt64& extraDataSize)
|
||||
}
|
||||
else
|
||||
{
|
||||
poco_check_ptr (_pHeader);
|
||||
_pHeader->setCRC(_crc32.checksum());
|
||||
_pHeader->setUncompressedSize(_bytesWritten);
|
||||
_pHeader->setCompressedSize(_ptrOHelper->bytesWritten());
|
||||
_pOstr->seekp(_pHeader->getStartPos(), std::ios_base::beg);
|
||||
poco_assert (*_pOstr);
|
||||
_pHeader->setStartPos(_pHeader->getStartPos()); // This resets EndPos now that compressed Size is known
|
||||
if (_pHeader->hasExtraField()) // Update sizes in header extension.
|
||||
_pHeader->setZip64Data();
|
||||
std::string header = _pHeader->createHeader();
|
||||
|
@ -24,12 +24,11 @@ endif(POCO_STATIC)
|
||||
|
||||
# OS Detection
|
||||
if(WIN32)
|
||||
target_compile_definitions(${BII_BLOCK_TARGET} INTERFACE -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE)
|
||||
target_compile_definitions(${BII_BLOCK_TARGET} INTERFACE -DUNICODE -D_UNICODE)
|
||||
#set(SYSLIBS iphlpapi gdi32 odbc32)
|
||||
endif(WIN32)
|
||||
|
||||
if (UNIX AND NOT ANDROID )
|
||||
target_compile_definitions(${BII_BLOCK_TARGET} INTERFACE -DPOCO_OS_FAMILY_UNIX )
|
||||
# Standard 'must be' defines
|
||||
if (APPLE)
|
||||
target_compile_definitions(${BII_BLOCK_TARGET} INTERFACE -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64)
|
||||
@ -81,4 +80,4 @@ find_package(APR)
|
||||
find_package(Apache2)
|
||||
if(APRUTIL_FOUND AND APACHE_FOUND)
|
||||
target_include_directories(${BII_BLOCK_TARGET} INTERFACE "${APACHE_INCLUDE_DIR}" "${APRUTIL_INCLUDE_DIR}" )
|
||||
endif(APRUTIL_FOUND AND APACHE_FOUND)
|
||||
endif(APRUTIL_FOUND AND APACHE_FOUND)
|
||||
|
@ -20,6 +20,8 @@ POCO_TARGET_OSARCH ?= x86_64
|
||||
POCO_HOST_OSARCH := $(POCO_TARGET_OSARCH)
|
||||
ARCHFLAGS ?= -arch $(POCO_TARGET_OSARCH)
|
||||
|
||||
OPENSSL_DIR ?= /usr/local/opt/openssl/
|
||||
|
||||
ifeq ($(POCO_TARGET_OSARCH),i386)
|
||||
RORELOCS = -read_only_relocs suppress
|
||||
endif
|
||||
@ -72,9 +74,9 @@ RELEASEOPT_LINK =
|
||||
#
|
||||
# System Specific Flags
|
||||
#
|
||||
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64
|
||||
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64 -I$(OPENSSL_DIR)/include
|
||||
|
||||
#
|
||||
# System Specific Libraries
|
||||
#
|
||||
SYSLIBS = -ldl
|
||||
SYSLIBS = -L$(OPENSSL_DIR)/lib -ldl
|
||||
|
@ -20,6 +20,11 @@ POCO_TARGET_OSARCH ?= x86_64
|
||||
POCO_HOST_OSARCH := $(POCO_TARGET_OSARCH)
|
||||
ARCHFLAGS ?= -arch $(POCO_TARGET_OSARCH)
|
||||
|
||||
OPENSSL_DIR ?= /usr/local/opt/openssl/
|
||||
|
||||
ifeq ($(POCO_TARGET_OSARCH),i386)
|
||||
RORELOCS = -read_only_relocs suppress
|
||||
endif
|
||||
|
||||
#
|
||||
# Tools
|
||||
@ -30,7 +35,7 @@ LINK = $(CXX) -bind_at_load
|
||||
LIB = libtool -static -o
|
||||
RANLIB = ranlib
|
||||
SHLIB = $(CXX) -dynamiclib -Wl,-install_name,$(POCO_LIB_INSTALLDIR)/$(notdir \$@) -o $@
|
||||
DYLIB = $(CXX) -dynamic -bundle -read_only_relocs suppress -Wl,-bind_at_load -o $@
|
||||
DYLIB = $(CXX) -dynamic -bundle $(RORELOCS) -Wl,-bind_at_load -o $@
|
||||
SHLIBLN = $(POCO_BASE)/build/script/shlibln
|
||||
STRIP =
|
||||
DEP = $(POCO_BASE)/build/script/makedepend.clang
|
||||
@ -69,9 +74,9 @@ RELEASEOPT_LINK =
|
||||
#
|
||||
# System Specific Flags
|
||||
#
|
||||
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64
|
||||
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64 -I$(OPENSSL_DIR)/include
|
||||
|
||||
#
|
||||
# System Specific Libraries
|
||||
#
|
||||
SYSLIBS = -ldl
|
||||
SYSLIBS = -L$(OPENSSL_DIR)/lib -ldl
|
||||
|
@ -40,11 +40,11 @@ if(MSVC)
|
||||
else(POCO_MT)
|
||||
set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE)
|
||||
endif(POCO_MT)
|
||||
|
||||
|
||||
if (ENABLE_MSVC_MP)
|
||||
add_definitions(/MP)
|
||||
endif()
|
||||
|
||||
|
||||
else(MSVC)
|
||||
# Other compilers then MSVC don't have a static STATIC_POSTFIX at the moment
|
||||
set(STATIC_POSTFIX "" CACHE STRING "Set static library postfix" FORCE)
|
||||
@ -55,12 +55,12 @@ if(POCO_STATIC)
|
||||
set(CMAKE_DEBUG_POSTFIX "${STATIC_POSTFIX}d" CACHE STRING "Set Debug library postfix" FORCE)
|
||||
set(CMAKE_RELEASE_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set Release library postfix" FORCE)
|
||||
set(CMAKE_MINSIZEREL_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set MinSizeRel library postfix" FORCE)
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX "${STATIC_POSTFIX}d" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
|
||||
else(POCO_STATIC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set Debug library postfix" FORCE)
|
||||
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set Release library postfix" FORCE)
|
||||
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "Set MinSizeRel library postfix" FORCE)
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX "d" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
@ -69,11 +69,10 @@ include(CheckTypeSize)
|
||||
find_package(Cygwin)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE -D__LCC__) #__LCC__ define used by MySQL.h
|
||||
add_definitions( -DUNICODE -D_UNICODE -D__LCC__) #__LCC__ define used by MySQL.h
|
||||
endif(WIN32)
|
||||
|
||||
if (UNIX AND NOT ANDROID )
|
||||
add_definitions( -DPOCO_OS_FAMILY_UNIX )
|
||||
# Standard 'must be' defines
|
||||
if (APPLE)
|
||||
add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64)
|
||||
@ -91,7 +90,6 @@ if (UNIX AND NOT ANDROID )
|
||||
endif(UNIX AND NOT ANDROID )
|
||||
|
||||
if (CMAKE_SYSTEM MATCHES "SunOS")
|
||||
add_definitions( -DPOCO_OS_FAMILY_UNIX )
|
||||
# Standard 'must be' defines
|
||||
add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
|
||||
set(SYSLIBS pthread socket xnet nsl resolv rt dl)
|
||||
|
22
configure
vendored
22
configure
vendored
@ -40,6 +40,15 @@ Options:
|
||||
--no-samples
|
||||
Do not build samples.
|
||||
|
||||
--minimal
|
||||
Build only Foundation, XML, JSON, Util and Net.
|
||||
|
||||
--typical (default)
|
||||
Build only Foundation, XML, JSON, Util, Net, Crypto, NetSSL, Data/SQLite and Zip.
|
||||
|
||||
--everything
|
||||
Build everything.
|
||||
|
||||
--no-wstring
|
||||
Compile with -DPOCO_NO_WSTRING.
|
||||
Useful if your C++ compiler does not support std::wstring
|
||||
@ -126,7 +135,6 @@ cd $build
|
||||
tests=1
|
||||
samples=1
|
||||
flags=""
|
||||
omit=""
|
||||
includepath=""
|
||||
librarypath=""
|
||||
odbclib=""
|
||||
@ -134,6 +142,9 @@ odbcinclude=""
|
||||
unbundled=""
|
||||
static=""
|
||||
shared=""
|
||||
omitMinimal="Crypto NetSSL_OpenSSL Zip Data Data/SQLite Data/ODBC Data/MySQL MongoDB PDF CppParser PageCompiler"
|
||||
omitTypical="Data/ODBC Data/MySQL MongoDB PDF CppParser"
|
||||
omit=$omitTypical
|
||||
# parse arguments
|
||||
while [ $# -ge 1 ]; do
|
||||
case "$1" in
|
||||
@ -199,6 +210,15 @@ while [ $# -ge 1 ]; do
|
||||
unbundled=1
|
||||
;;
|
||||
|
||||
--minimal)
|
||||
omit=$omitMinimal ;;
|
||||
|
||||
--typical)
|
||||
omit=$omitTypical ;;
|
||||
|
||||
--everything)
|
||||
omit="" ;;
|
||||
|
||||
--static)
|
||||
static=1 ;;
|
||||
|
||||
|
@ -241,7 +241,7 @@ install: libexecs
|
||||
mkdir -p $(INSTALLDIR)/include/Poco
|
||||
mkdir -p $(INSTALLDIR)/lib
|
||||
mkdir -p $(INSTALLDIR)/bin
|
||||
for comp in $(COMPONENTS) ; do \
|
||||
for comp in $(filter-out $(foreach f,$(OMIT),$f%),$(COMPONENTS)) ; do \
|
||||
if [ -d "$(POCO_BASE)/$$comp/include" ] ; then \
|
||||
cp -Rf $(POCO_BASE)/$$comp/include/* $(INSTALLDIR)/include/ ; \
|
||||
fi ; \
|
||||
|
Loading…
x
Reference in New Issue
Block a user