mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 11:05:56 +00:00
Make IResponse.Headers a readonly dictionary
This commit is contained in:
@@ -111,9 +111,9 @@ namespace Octokit.Tests.Http
|
||||
string headerKey,
|
||||
string otpHeaderValue)
|
||||
{
|
||||
var headers = new Dictionary<string, string> { { headerKey, otpHeaderValue } };
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
IResponse response = new Response { StatusCode = HttpStatusCode.Unauthorized };
|
||||
response.Headers[headerKey] = otpHeaderValue;
|
||||
IResponse response = new Response(HttpStatusCode.Unauthorized, null, headers, "application/json");
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
_exampleUri,
|
||||
@@ -138,12 +138,9 @@ namespace Octokit.Tests.Http
|
||||
string otpHeaderValue,
|
||||
TwoFactorType expectedFactorType)
|
||||
{
|
||||
var headers = new Dictionary<string, string> { { headerKey, otpHeaderValue } };
|
||||
IResponse response = new Response(HttpStatusCode.Unauthorized, null, headers, "application/json");
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
IResponse response = new Response
|
||||
{
|
||||
StatusCode = HttpStatusCode.Unauthorized,
|
||||
};
|
||||
response.Headers[headerKey] = otpHeaderValue;
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
_exampleUri,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
namespace Octokit.Internal
|
||||
@@ -17,7 +15,7 @@ namespace Octokit.Internal
|
||||
|
||||
var body = response.Body is T ? (T)response.Body : default(T);
|
||||
HttpResponse = response;
|
||||
Headers = new ReadOnlyDictionary<string, string>(response.Headers);
|
||||
Headers = response.Headers;
|
||||
Body = body;
|
||||
ApiInfo = response.ApiInfo;
|
||||
StatusCode = response.StatusCode;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Octokit
|
||||
public interface IResponse
|
||||
{
|
||||
object Body { get; }
|
||||
IDictionary<string, string> Headers { get; }
|
||||
IReadOnlyDictionary<string, string> Headers { get; }
|
||||
ApiInfo ApiInfo { get; }
|
||||
HttpStatusCode StatusCode { get; }
|
||||
string ContentType { get; }
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit.Internal
|
||||
@@ -17,7 +15,7 @@ namespace Octokit.Internal
|
||||
{
|
||||
Ensure.ArgumentNotNull(headers, "headers");
|
||||
|
||||
Headers = headers;
|
||||
Headers = new ReadOnlyDictionary<string, string>(headers);
|
||||
ApiInfo = ApiInfoParser.ParseResponseHeaders(headers);
|
||||
}
|
||||
|
||||
@@ -27,13 +25,13 @@ namespace Octokit.Internal
|
||||
|
||||
StatusCode = statusCode;
|
||||
Body = body;
|
||||
Headers = headers;
|
||||
Headers = new ReadOnlyDictionary<string, string>(headers);
|
||||
ApiInfo = ApiInfoParser.ParseResponseHeaders(headers);
|
||||
ContentType = contentType;
|
||||
}
|
||||
|
||||
public object Body { get; set; }
|
||||
public IDictionary<string, string> Headers { get; private set; }
|
||||
public IReadOnlyDictionary<string, string> Headers { get; private set; }
|
||||
public ApiInfo ApiInfo { get; private set; }
|
||||
public HttpStatusCode StatusCode { get; set; }
|
||||
public string ContentType { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user