Skip to content

Commit 5444ac0

Browse files
committed
client WebSocket fixes
1 parent 364536c commit 5444ac0

4 files changed

Lines changed: 9 additions & 19 deletions

File tree

Net/include/Poco/Net/HTTPRequest.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPRequest.h
33
//
4-
// $Id: //poco/1.4/Net/include/Poco/Net/HTTPRequest.h#2 $
4+
// $Id: //poco/1.4/Net/include/Poco/Net/HTTPRequest.h#3 $
55
//
66
// Library: Net
77
// Package: HTTP
@@ -161,6 +161,7 @@ class Net_API HTTPRequest: public HTTPMessage
161161
static const std::string COOKIE;
162162
static const std::string AUTHORIZATION;
163163
static const std::string PROXY_AUTHORIZATION;
164+
static const std::string UPGRADE;
164165

165166
protected:
166167
void getCredentials(const std::string& header, std::string& scheme, std::string& authInfo) const;

Net/src/HTTPClientSession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPClientSession.cpp
33
//
4-
// $Id: //poco/1.4/Net/src/HTTPClientSession.cpp#10 $
4+
// $Id: //poco/1.4/Net/src/HTTPClientSession.cpp#11 $
55
//
66
// Library: Net
77
// Package: HTTPClient
@@ -223,7 +223,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
223223
#endif
224224
request.write(*_pRequestStream);
225225
}
226-
else if (request.getMethod() != HTTPRequest::HTTP_PUT && request.getMethod() != HTTPRequest::HTTP_POST)
226+
else if ((request.getMethod() != HTTPRequest::HTTP_PUT && request.getMethod() != HTTPRequest::HTTP_POST) || request.has(HTTPRequest::UPGRADE))
227227
{
228228
Poco::CountingOutputStream cs;
229229
request.write(cs);

Net/src/HTTPRequest.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPRequest.cpp
33
//
4-
// $Id: //poco/1.4/Net/src/HTTPRequest.cpp#3 $
4+
// $Id: //poco/1.4/Net/src/HTTPRequest.cpp#4 $
55
//
66
// Library: Net
77
// Package: HTTP
@@ -61,6 +61,7 @@ const std::string HTTPRequest::HOST = "Host";
6161
const std::string HTTPRequest::COOKIE = "Cookie";
6262
const std::string HTTPRequest::AUTHORIZATION = "Authorization";
6363
const std::string HTTPRequest::PROXY_AUTHORIZATION = "Proxy-Authorization";
64+
const std::string HTTPRequest::UPGRADE = "Upgrade";
6465

6566

6667
HTTPRequest::HTTPRequest():
@@ -118,19 +119,7 @@ void HTTPRequest::setHost(const std::string& host)
118119

119120
void HTTPRequest::setHost(const std::string& host, Poco::UInt16 port)
120121
{
121-
std::string value;
122-
if (host.find(':') != std::string::npos)
123-
{
124-
// IPv6 address
125-
value.append("[");
126-
value.append(host);
127-
value.append("]");
128-
}
129-
else
130-
{
131-
value.append(host);
132-
}
133-
122+
std::string value(host);
134123
if (port != 80 && port != 443)
135124
{
136125
value.append(":");

Net/src/WebSocket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// WebSocket.cpp
33
//
4-
// $Id: //poco/1.4/Net/src/WebSocket.cpp#7 $
4+
// $Id: //poco/1.4/Net/src/WebSocket.cpp#8 $
55
//
66
// Library: Net
77
// Package: WebSocket
@@ -224,7 +224,7 @@ WebSocketImpl* WebSocket::completeHandshake(HTTPClientSession& cs, HTTPResponse&
224224
std::string accept = response.get("Sec-WebSocket-Accept", "");
225225
if (accept != computeAccept(key))
226226
throw WebSocketException("Invalid or missing Sec-WebSocket-Accept header in handshake response", WS_ERR_NO_HANDSHAKE);
227-
return new WebSocketImpl(static_cast<StreamSocketImpl*>(cs.socket().impl()), true);
227+
return new WebSocketImpl(static_cast<StreamSocketImpl*>(cs.detachSocket().impl()), true);
228228
}
229229

230230

0 commit comments

Comments
 (0)