public HttpResponseWrapper GetResponse()
 {
     _lastResponse = new HttpResponseWrapper((HttpWebResponse) _currentRequest.GetResponse());
     NextLocation = getNextLocation(_lastResponse);
     return _lastResponse;
 }
 private static string getNextLocation(HttpResponseWrapper response)
 {
     var location = response.Location;
     if (!location.IsNullOrEmpty()) return location;
     location = response.FindRedirectUrl();
     return location;
 }
 public HttpResponseWrapper GetNextResponse( )
 {
     bool authError = false;
     HttpWebRequest request;
     if (!Uri.IsWellFormedUriString(NextLocation, UriKind.Absolute))
         NextLocation = ExtractHost(_lastLoc) + NextLocation;
     request = GetRequest(NextLocation, "", "");
     //request.Headers.Add("Authorization", "Basic " + authStr);
     var cookParser = SetCookieParser.Create(_lastResponse.Headers);
     _sessionContainer.AddNewSessionsFrom(cookParser);
     request.Headers.Add("Cookie", _sessionContainer.GetText(NextLocation));
     addAuthentication(request);
     try
     {
         _lastResponse = GetResponse();
         //_authenticate = false;
     }
     catch (WebException we)
     {
         if (we.Message == "The remote server returned an error: (401) Unauthorized.")
         {
             _authenticate = true;
         }
         authError = true;
     }
     if (authError) return _lastResponse;
     NextLocation = _lastResponse.Location;
     if (!NextLocation.IsNullOrEmpty()) return _lastResponse;
     NextLocation = _lastResponse.FindRedirectUrl();
     return _lastResponse;
 }