diff --git a/Listener.cpp b/Listener.cpp index 52d66184..95ac4a62 100644 --- a/Listener.cpp +++ b/Listener.cpp @@ -76,6 +76,19 @@ CIncomingConnection::CIncomingConnection(const CString& sHostname, unsigned shor EnableReadLine(); } +void CIncomingConnection::ReachedMaxBuffer() { + if (GetCloseType() != CLT_DONT) + return; // Already closing + + // We don't actually SetMaxBufferThreshold() because that would be + // inherited by sockets after SwapSockByAddr(). + if (GetInternalReadBuffer().length() <= 4096) + return; + + // We should never get here with legitimate requests :/ + Close(); +} + void CIncomingConnection::ReadLine(const CString& sLine) { bool bIsHTTP = (sLine.WildCmp("GET * HTTP/1.?\r\n") || sLine.WildCmp("POST * HTTP/1.?\r\n")); bool bAcceptHTTP = (m_eAcceptType == CListener::ACCEPT_ALL) diff --git a/Listener.h b/Listener.h index 709c4585..28550411 100644 --- a/Listener.h +++ b/Listener.h @@ -78,6 +78,7 @@ public: CIncomingConnection(const CString& sHostname, unsigned short uPort, CListener::EAcceptType eAcceptType); virtual ~CIncomingConnection() {} virtual void ReadLine(const CString& sData); + virtual void ReachedMaxBuffer(); private: CListener::EAcceptType m_eAcceptType;