private HttpResponse Navigate(HttpRequest request, HttpBehavior httpBehavior) { bool ContinueRedirect = true; HttpResponse response = null; HttpConnectionFactory connFactory = new HttpConnectionFactory(); HttpConnection connection = connFactory.GetConnnection(request.Uri, this.m_proxy); HttpBehavior.RedirectStep rs = null; string redirectUri = null; int responseCode = 0; int redirectCounter = 0; try { while (ContinueRedirect) { try { response = SendRequestAndGetResponse(connection, request); redirectUri = response.Location; responseCode = response.ResponseCode; // response code 100 means that we need to wait for another response // and receive the response from the socket again on the same connection if (responseCode == 100) { response = GetResponse(connection); redirectUri = response.Location; responseCode = response.ResponseCode; } if (httpBehavior != null) { rs = httpBehavior.GetNextStep(); rs.Compare(responseCode, redirectUri); ContinueRedirect = !httpBehavior.IsEmpty(); } else { ContinueRedirect = (redirectCounter < this.m_maxRedirects && (responseCode == 301 || responseCode == 302)); redirectCounter++; } if (ContinueRedirect) { request = new HttpGet(new Uri(redirectUri)); // make sure the connection is still open and redirect url is from the same host connection = connFactory.GetConnnection(request.Uri, this.m_proxy, connection); } } catch (Exception ex) { int i = 0; throw ex; } } } finally { connection.Close(); } return response; }
internal HttpsConnection(HttpConnectionFactory factory, Uri uri, Uri proxy, Certificate clientCertificates, AsymmetricKeyParameter asymmetricKeyParameter, Action<Certificate> serverCertificateValidator) : base(factory, uri, proxy) { _tlsClient = new CustomTlsClient(clientCertificates, asymmetricKeyParameter, serverCertificateValidator); }
internal HttpConnection(HttpConnectionFactory factory, Uri uri, Uri proxy) { this.m_factory = factory; this.m_uri = uri; this.m_proxy = proxy; }
private Connection GetConnectionForUriScheme(HttpConnectionFactory connFactory, Uri uri) { Connection connection; if (uri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.InvariantCultureIgnoreCase)) connection = connFactory.GetConnection(uri, _proxy, _asymmetricKeyParameter, _clientCertificates, _serverCertificateValidator); else connection = connFactory.GetConnnection(uri, this._proxy); return connection; }
protected Connection(HttpConnectionFactory factory, Uri uri, Uri proxy) { _factory = factory; Uri = uri; _proxy = proxy; }
internal HttpConnection(HttpConnectionFactory factory, Uri uri, Uri proxy) :base(factory, uri, proxy) { }