using System.Collections.Generic; using System.Collections.ObjectModel; using System.Net; namespace Octokit.Internal { /// /// Represents a generic HTTP response /// internal class Response : IResponse { public Response() : this(new Dictionary()) { } public Response(IDictionary headers) { Ensure.ArgumentNotNull(headers, "headers"); Headers = new ReadOnlyDictionary(headers); ApiInfo = ApiInfoParser.ParseResponseHeaders(headers); } public Response(HttpStatusCode statusCode, object body, IDictionary headers, string contentType) { Ensure.ArgumentNotNull(headers, "headers"); StatusCode = statusCode; Body = body; Headers = new ReadOnlyDictionary(headers); ApiInfo = ApiInfoParser.ParseResponseHeaders(headers); ContentType = contentType; } /// /// Raw response body. Typically a string, but when requesting images, it will be a byte array. /// public object Body { get; private set; } /// /// Information about the API. /// public IReadOnlyDictionary Headers { get; private set; } /// /// Information about the API response parsed from the response headers. /// public ApiInfo ApiInfo { get; internal set; } // This setter is internal for use in tests. /// /// The response status code. /// public HttpStatusCode StatusCode { get; private set; } /// /// The content type of the response. /// public string ContentType { get; private set; } } }