Skip to content

Commit 4ec68ce

Browse files
committed
fixed SF# 1956300: HTTPServerConnection hanging
1 parent 2ba1d41 commit 4ec68ce

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

Net/include/Poco/Net/HTTPSession.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPSession.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/HTTPSession.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/HTTPSession.h#5 $
55
//
66
// Library: Net
77
// Package: HTTP
@@ -140,6 +140,9 @@ class Net_API HTTPSession
140140

141141
int receive(char* buffer, int length);
142142
/// Reads up to length bytes.
143+
144+
int buffered() const;
145+
/// Returns the number of bytes in the buffer.
143146

144147
StreamSocket& socket();
145148
/// Returns a reference to the underlying socket.
@@ -208,6 +211,12 @@ inline const Poco::Exception* HTTPSession::networkException() const
208211
}
209212

210213

214+
inline int HTTPSession::buffered() const
215+
{
216+
return static_cast<int>(_pEnd - _pCurrent);
217+
}
218+
219+
211220
} } // namespace Poco::Net
212221

213222

Net/src/HTTPServerSession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPServerSession.cpp
33
//
4-
// $Id: //poco/svn/Net/src/HTTPServerSession.cpp#2 $
4+
// $Id: //poco/Main/Net/src/HTTPServerSession.cpp#9 $
55
//
66
// Library: Net
77
// Package: HTTPServer
@@ -70,7 +70,7 @@ bool HTTPServerSession::hasMoreRequests()
7070
{
7171
if (_maxKeepAliveRequests > 0)
7272
--_maxKeepAliveRequests;
73-
return socket().poll(_keepAliveTimeout, Socket::SELECT_READ);
73+
return buffered() > 0 || socket().poll(_keepAliveTimeout, Socket::SELECT_READ);
7474
}
7575
else return false;
7676
}

0 commit comments

Comments
 (0)