internal void Close(bool force) { if (_socket == null) { return; } lock (_sync) { if (_socket != null) { if (force) { goto IL_00bf; } GetResponseStream().Close(); HttpListenerRequest request = _context.Request; HttpListenerResponse response = _context.Response; if (!request.KeepAlive || response.CloseConnection || !request.FlushInput() || (_chunked && (!_chunked || response.ForceCloseChunked))) { goto IL_00bf; } _reuses++; disposeRequestBuffer(); unbind(); init(); BeginReadRequest(); } goto end_IL_0019; IL_00bf: close(); end_IL_0019 :; } }
internal void Close(bool force) { if (this._socket == null) { return; } if (this._outputStream != null) { this._outputStream.Close(); this._outputStream = null; } HttpListenerRequest request = this._context.Request; HttpListenerResponse response = this._context.Response; force |= !request.KeepAlive; if (!force) { force = (response.Headers["Connection"] == "close"); } if (!force && request.FlushInput() && (!this._chunked || (this._chunked && !response.ForceCloseChunked))) { this._reuses++; this.unbind(); this.init(); this.BeginReadRequest(); return; } Socket socket = this._socket; this._socket = null; try { socket.Shutdown(SocketShutdown.Both); } catch { } finally { if (socket != null) { socket.Close(); } } this.unbind(); this.removeConnection(); }