Пример #1
0
        private IResource ParseResponse(HttpRemoteResponse response)
        {
            if (response.StatusCode >= HttpStatusCode.BadRequest ||
                response.HasNoContent() || !response.Headers.ContainsKey("Content-Type"))
            {
                return(new EmptyResource(response));
            }

            string    contentType = response.Headers["Content-Type"];
            IResource resource    = CreateResource(contentType, response);

            if (resource != null)
            {
                return(resource);
            }

            throw new InvalidOperationException("unsupported media type: " + response.Headers["Content-Type"]);
        }
Пример #2
0
 protected bool ShouldRedirect(HttpRemoteResponse response) {
     return (int)response.StatusCode / 100 == 3 || (
            response.StatusCode == HttpStatusCode.Created && response.HasNoContent());
 }