mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-17 07:13:27 +02:00
client WebSocket fixes
This commit is contained in:
parent
364536c5fd
commit
5444ac07f5
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPRequest.h
|
// HTTPRequest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.4/Net/include/Poco/Net/HTTPRequest.h#2 $
|
// $Id: //poco/1.4/Net/include/Poco/Net/HTTPRequest.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: HTTP
|
// Package: HTTP
|
||||||
@ -161,6 +161,7 @@ public:
|
|||||||
static const std::string COOKIE;
|
static const std::string COOKIE;
|
||||||
static const std::string AUTHORIZATION;
|
static const std::string AUTHORIZATION;
|
||||||
static const std::string PROXY_AUTHORIZATION;
|
static const std::string PROXY_AUTHORIZATION;
|
||||||
|
static const std::string UPGRADE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void getCredentials(const std::string& header, std::string& scheme, std::string& authInfo) const;
|
void getCredentials(const std::string& header, std::string& scheme, std::string& authInfo) const;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPClientSession.cpp
|
// HTTPClientSession.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.4/Net/src/HTTPClientSession.cpp#10 $
|
// $Id: //poco/1.4/Net/src/HTTPClientSession.cpp#11 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: HTTPClient
|
// Package: HTTPClient
|
||||||
@ -223,7 +223,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
|
|||||||
#endif
|
#endif
|
||||||
request.write(*_pRequestStream);
|
request.write(*_pRequestStream);
|
||||||
}
|
}
|
||||||
else if (request.getMethod() != HTTPRequest::HTTP_PUT && request.getMethod() != HTTPRequest::HTTP_POST)
|
else if ((request.getMethod() != HTTPRequest::HTTP_PUT && request.getMethod() != HTTPRequest::HTTP_POST) || request.has(HTTPRequest::UPGRADE))
|
||||||
{
|
{
|
||||||
Poco::CountingOutputStream cs;
|
Poco::CountingOutputStream cs;
|
||||||
request.write(cs);
|
request.write(cs);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPRequest.cpp
|
// HTTPRequest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.4/Net/src/HTTPRequest.cpp#3 $
|
// $Id: //poco/1.4/Net/src/HTTPRequest.cpp#4 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: HTTP
|
// Package: HTTP
|
||||||
@ -61,6 +61,7 @@ const std::string HTTPRequest::HOST = "Host";
|
|||||||
const std::string HTTPRequest::COOKIE = "Cookie";
|
const std::string HTTPRequest::COOKIE = "Cookie";
|
||||||
const std::string HTTPRequest::AUTHORIZATION = "Authorization";
|
const std::string HTTPRequest::AUTHORIZATION = "Authorization";
|
||||||
const std::string HTTPRequest::PROXY_AUTHORIZATION = "Proxy-Authorization";
|
const std::string HTTPRequest::PROXY_AUTHORIZATION = "Proxy-Authorization";
|
||||||
|
const std::string HTTPRequest::UPGRADE = "Upgrade";
|
||||||
|
|
||||||
|
|
||||||
HTTPRequest::HTTPRequest():
|
HTTPRequest::HTTPRequest():
|
||||||
@ -118,19 +119,7 @@ void HTTPRequest::setHost(const std::string& host)
|
|||||||
|
|
||||||
void HTTPRequest::setHost(const std::string& host, Poco::UInt16 port)
|
void HTTPRequest::setHost(const std::string& host, Poco::UInt16 port)
|
||||||
{
|
{
|
||||||
std::string value;
|
std::string value(host);
|
||||||
if (host.find(':') != std::string::npos)
|
|
||||||
{
|
|
||||||
// IPv6 address
|
|
||||||
value.append("[");
|
|
||||||
value.append(host);
|
|
||||||
value.append("]");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
value.append(host);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port != 80 && port != 443)
|
if (port != 80 && port != 443)
|
||||||
{
|
{
|
||||||
value.append(":");
|
value.append(":");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// WebSocket.cpp
|
// WebSocket.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.4/Net/src/WebSocket.cpp#7 $
|
// $Id: //poco/1.4/Net/src/WebSocket.cpp#8 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: WebSocket
|
// Package: WebSocket
|
||||||
@ -224,7 +224,7 @@ WebSocketImpl* WebSocket::completeHandshake(HTTPClientSession& cs, HTTPResponse&
|
|||||||
std::string accept = response.get("Sec-WebSocket-Accept", "");
|
std::string accept = response.get("Sec-WebSocket-Accept", "");
|
||||||
if (accept != computeAccept(key))
|
if (accept != computeAccept(key))
|
||||||
throw WebSocketException("Invalid or missing Sec-WebSocket-Accept header in handshake response", WS_ERR_NO_HANDSHAKE);
|
throw WebSocketException("Invalid or missing Sec-WebSocket-Accept header in handshake response", WS_ERR_NO_HANDSHAKE);
|
||||||
return new WebSocketImpl(static_cast<StreamSocketImpl*>(cs.socket().impl()), true);
|
return new WebSocketImpl(static_cast<StreamSocketImpl*>(cs.detachSocket().impl()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user