/// <summary> /// Ends the get response. /// </summary> /// <returns></returns> /// <exception cref="InvalidOperationException"> /// Network is null or can't read /// or /// </exception> public WebResponse EndGetResponse() { if (_networkStream == null || !_networkStream.CanRead) { throw new InvalidOperationException("Network is null or can't read"); } HttpStatusCode responseStatusCode; var responseHeaders = BuildResponseHeaders(out responseStatusCode); Uri uri; string method; Exception error = null; var autoRedirect = 1; // Check for redirect options while (CheckForRedirection(responseStatusCode, responseHeaders, out uri, out method, ref error, ref autoRedirect)) { autoRedirect++; Address = uri; Method = Method; _socksConnection.Close(); _socksConnection.Dispose(); _networkStream.Close(); _networkStream.Dispose(); BeginGetResponse(); responseHeaders = BuildResponseHeaders(out responseStatusCode); } return(new HttpWebResponseSocks(Address, Method.ToKnownHttpVerb(), responseStatusCode, responseHeaders, _networkStream)); }
protected override void Dispose(bool disposing) #endif { if (disposing) { Close(); try { _socksConnection?.Dispose(); _responseStream?.Dispose(); } finally { _socksConnection = null; _responseStream = null; } } #if !NET40 base.Dispose(disposing); #endif }