public HttpRemoteResponse Process(ResponseChain chain, HttpRemoteResponse response)
        {
            response = chain.Next(response);

            if (!ShouldRedirect(response))
                return response;

            string uri;

            if (response.Headers.TryGetValue("Location", out uri) && !String.IsNullOrWhiteSpace(uri)) {
                chain.Reset();

                response = chain.Service.Dispatcher.Process(chain.Service, "GET", new Uri(uri), null);
                response = chain.Next(response);
            }

            return response;
        }
예제 #2
0
        public HttpRemoteResponse Process(ResponseChain chain, HttpRemoteResponse response)
        {
            if (!chain.Service.IsAsynch)
                throw new NotSupportedException("AutoRefresh is not supported on synchronous requests");

            response = chain.Next(response);

            Refresh refresh;

            if (!ShouldRefresh(response, out refresh) || refresh == null)
                return response;

            Thread.Sleep(TimeSpan.FromSeconds(refresh.Seconds)); // TODO: use a better alternative

            response = chain.Service.Dispatcher.Process(chain.Service, "GET", new Uri(refresh.Uri), null);
            response = chain.Next(response);

            return response;
        }