/// <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)); }
/// <summary> /// Closes this instance. /// </summary> public override void Close() { try { _responseStream?.Close(); } catch (Exception) { // TODO manage error } try { _socksConnection.Disconnect(false); _socksConnection?.Close(); } catch (Exception) { // TODO manage error } }