Fix for force close in HttpConnection.cs
This commit is contained in:
parent
72565cc8fe
commit
f85f227a79
@ -204,6 +204,7 @@ namespace WebSocketSharp.Net
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_inputStream = null;
|
_inputStream = null;
|
||||||
|
_outputStream = null;
|
||||||
_websocketStream = null;
|
_websocketStream = null;
|
||||||
|
|
||||||
_stream.Dispose ();
|
_stream.Dispose ();
|
||||||
@ -415,29 +416,24 @@ namespace WebSocketSharp.Net
|
|||||||
if (_socket == null)
|
if (_socket == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_outputStream != null) {
|
if (!force) {
|
||||||
_outputStream.Close ();
|
GetResponseStream ().Close ();
|
||||||
_outputStream = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var req = _context.Request;
|
var req = _context.Request;
|
||||||
var res = _context.Response;
|
var res = _context.Response;
|
||||||
|
if (req.KeepAlive &&
|
||||||
|
!res.CloseConnection &&
|
||||||
|
req.FlushInput () &&
|
||||||
|
(!_chunked || (_chunked && !res.ForceCloseChunked))) {
|
||||||
|
// Don't close. Keep working.
|
||||||
|
_reuses++;
|
||||||
|
disposeRequestBuffer ();
|
||||||
|
unbind ();
|
||||||
|
init ();
|
||||||
|
BeginReadRequest ();
|
||||||
|
|
||||||
force |= !req.KeepAlive;
|
return;
|
||||||
if (!force)
|
}
|
||||||
force = res.Headers ["Connection"] == "close";
|
|
||||||
|
|
||||||
if (!force &&
|
|
||||||
req.FlushInput () &&
|
|
||||||
(!_chunked || (_chunked && !res.ForceCloseChunked))) {
|
|
||||||
// Don't close. Keep working.
|
|
||||||
_reuses++;
|
|
||||||
disposeRequestBuffer ();
|
|
||||||
unbind ();
|
|
||||||
init ();
|
|
||||||
BeginReadRequest ();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close ();
|
close ();
|
||||||
|
@ -91,6 +91,12 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
#region Internal Properties
|
#region Internal Properties
|
||||||
|
|
||||||
|
internal bool CloseConnection {
|
||||||
|
get {
|
||||||
|
return _headers ["Connection"] == "close";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal bool ForceCloseChunked {
|
internal bool ForceCloseChunked {
|
||||||
get {
|
get {
|
||||||
return _forceCloseChunked;
|
return _forceCloseChunked;
|
||||||
@ -242,6 +248,7 @@ namespace WebSocketSharp.Net
|
|||||||
/// </exception>
|
/// </exception>
|
||||||
public WebHeaderCollection Headers {
|
public WebHeaderCollection Headers {
|
||||||
get {
|
get {
|
||||||
|
checkDisposed ();
|
||||||
return _headers;
|
return _headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user