From d9f95173091ed8c03999e59ba1728ff6c4aa1fff Mon Sep 17 00:00:00 2001 From: jonnii Date: Mon, 8 Jan 2018 20:21:08 -0500 Subject: [PATCH] [Feature] Internalize --- .../Fixtures/HttpResponses.cs | 2 +- .../ParsedHeaderSpecs.cs | 26 --------------- src/SpeakEasy/Bodies/FileUploadBody.cs | 2 +- src/SpeakEasy/Bodies/ObjectRequestBody.cs | 2 +- src/SpeakEasy/Contents/ByteArrayContent.cs | 2 +- src/SpeakEasy/Contents/StreamableContent.cs | 2 +- src/SpeakEasy/HttpClient.cs | 6 +--- src/SpeakEasy/HttpResponse.cs | 2 +- src/SpeakEasy/HttpResponseState.cs | 2 +- src/SpeakEasy/IHttpWebResponse.cs | 4 +-- src/SpeakEasy/ParsedHeaderParameter.cs | 15 --------- src/SpeakEasy/ParsedHeaderValue.cs | 33 ------------------- src/SpeakEasy/RequestRunner.cs | 2 +- src/SpeakEasy/TransmissionSettings.cs | 2 +- 14 files changed, 12 insertions(+), 90 deletions(-) delete mode 100644 src/SpeakEasy.Specifications/ParsedHeaderSpecs.cs delete mode 100644 src/SpeakEasy/ParsedHeaderParameter.cs delete mode 100644 src/SpeakEasy/ParsedHeaderValue.cs diff --git a/src/SpeakEasy.Specifications/Fixtures/HttpResponses.cs b/src/SpeakEasy.Specifications/Fixtures/HttpResponses.cs index e058ba4..4642f1a 100644 --- a/src/SpeakEasy.Specifications/Fixtures/HttpResponses.cs +++ b/src/SpeakEasy.Specifications/Fixtures/HttpResponses.cs @@ -4,7 +4,7 @@ namespace SpeakEasy.Specifications.Fixtures { - public static class HttpResponses + internal static class HttpResponses { public static HttpResponse Create(ISerializer serializer, Stream bodyStream, HttpStatusCode code) { diff --git a/src/SpeakEasy.Specifications/ParsedHeaderSpecs.cs b/src/SpeakEasy.Specifications/ParsedHeaderSpecs.cs deleted file mode 100644 index 7c8de40..0000000 --- a/src/SpeakEasy.Specifications/ParsedHeaderSpecs.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using Machine.Specifications; - -namespace SpeakEasy.Specifications -{ - [Subject(typeof(ParsedHeaderValue))] - class ParsedHeaderSpecs - { - class when_getting_unknown_parameter - { - static ParsedHeaderValue headerValue; - - static Exception exception; - - Establish context = () => - headerValue = new ParsedHeaderValue(new Dictionary { { "parameter", new[] { new ParsedHeaderParameter("name", "value") } } }); - - Because of = () => - exception = Catch.Exception(() => headerValue.GetParameter("unknown", "fribble")); - - It should_throw_exception = () => - exception.ShouldBeOfExactType(); - } - } -} diff --git a/src/SpeakEasy/Bodies/FileUploadBody.cs b/src/SpeakEasy/Bodies/FileUploadBody.cs index dc9d626..4a6b5ff 100644 --- a/src/SpeakEasy/Bodies/FileUploadBody.cs +++ b/src/SpeakEasy/Bodies/FileUploadBody.cs @@ -2,7 +2,7 @@ namespace SpeakEasy.Bodies { - public class FileUploadBody : IRequestBody + internal class FileUploadBody : IRequestBody { private readonly Resource resource; diff --git a/src/SpeakEasy/Bodies/ObjectRequestBody.cs b/src/SpeakEasy/Bodies/ObjectRequestBody.cs index c76397e..bd87994 100644 --- a/src/SpeakEasy/Bodies/ObjectRequestBody.cs +++ b/src/SpeakEasy/Bodies/ObjectRequestBody.cs @@ -2,7 +2,7 @@ namespace SpeakEasy.Bodies { - public class ObjectRequestBody : IRequestBody + internal class ObjectRequestBody : IRequestBody { private readonly object body; diff --git a/src/SpeakEasy/Contents/ByteArrayContent.cs b/src/SpeakEasy/Contents/ByteArrayContent.cs index a8aaaa5..ffb957c 100644 --- a/src/SpeakEasy/Contents/ByteArrayContent.cs +++ b/src/SpeakEasy/Contents/ByteArrayContent.cs @@ -6,7 +6,7 @@ namespace SpeakEasy.Contents { - public class ByteArrayContent : IContent + internal class ByteArrayContent : IContent { public ByteArrayContent(string contentType, byte[] bytes) { diff --git a/src/SpeakEasy/Contents/StreamableContent.cs b/src/SpeakEasy/Contents/StreamableContent.cs index 6de5372..7e15b33 100644 --- a/src/SpeakEasy/Contents/StreamableContent.cs +++ b/src/SpeakEasy/Contents/StreamableContent.cs @@ -7,7 +7,7 @@ namespace SpeakEasy.Contents { - public class StreamableContent : IContent + internal class StreamableContent : IContent { private readonly Func onStream; diff --git a/src/SpeakEasy/HttpClient.cs b/src/SpeakEasy/HttpClient.cs index fba01ac..8181a3a 100644 --- a/src/SpeakEasy/HttpClient.cs +++ b/src/SpeakEasy/HttpClient.cs @@ -80,13 +80,9 @@ internal System.Net.Http.HttpClient BuildSystemClient(CookieContainer cookieCont var handler = new HttpClientHandler { AllowAutoRedirect = false, - //MaxAutomaticRedirections = 0, - UseDefaultCredentials = false, CookieContainer = cookieContainer, - AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip | DecompressionMethods.None, - //ClientCertificates = { }, - //Proxy = + AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip | DecompressionMethods.None }; settings.Authenticator.Authenticate(handler); diff --git a/src/SpeakEasy/HttpResponse.cs b/src/SpeakEasy/HttpResponse.cs index aa53fbe..4cee5db 100644 --- a/src/SpeakEasy/HttpResponse.cs +++ b/src/SpeakEasy/HttpResponse.cs @@ -5,7 +5,7 @@ namespace SpeakEasy { - public class HttpResponse : IHttpResponse + internal class HttpResponse : IHttpResponse { private readonly ISerializer deserializer; diff --git a/src/SpeakEasy/HttpResponseState.cs b/src/SpeakEasy/HttpResponseState.cs index be44bb2..ddb50ba 100644 --- a/src/SpeakEasy/HttpResponseState.cs +++ b/src/SpeakEasy/HttpResponseState.cs @@ -7,7 +7,7 @@ namespace SpeakEasy /// /// The http response state contains the details of an http response, for example cookies and headers. /// - public class HttpResponseState : IHttpResponseState + internal class HttpResponseState : IHttpResponseState { private readonly HttpResponseMessage httpResponseMessage; diff --git a/src/SpeakEasy/IHttpWebResponse.cs b/src/SpeakEasy/IHttpWebResponse.cs index 97d5cb2..186716f 100644 --- a/src/SpeakEasy/IHttpWebResponse.cs +++ b/src/SpeakEasy/IHttpWebResponse.cs @@ -33,6 +33,6 @@ public interface IHttpWebResponse : IDisposable /// Builds the http response state from this http web response /// /// An http response state - HttpResponseState BuildState(); + IHttpResponseState BuildState(); } -} \ No newline at end of file +} diff --git a/src/SpeakEasy/ParsedHeaderParameter.cs b/src/SpeakEasy/ParsedHeaderParameter.cs deleted file mode 100644 index fb016ce..0000000 --- a/src/SpeakEasy/ParsedHeaderParameter.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace SpeakEasy -{ - internal class ParsedHeaderParameter - { - public ParsedHeaderParameter(string name, string value) - { - Name = name; - Value = value; - } - - public string Name { get; } - - public string Value { get; } - } -} diff --git a/src/SpeakEasy/ParsedHeaderValue.cs b/src/SpeakEasy/ParsedHeaderValue.cs deleted file mode 100644 index 8c5b987..0000000 --- a/src/SpeakEasy/ParsedHeaderValue.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace SpeakEasy -{ - internal class ParsedHeaderValue - { - private readonly IDictionary parameters; - - public ParsedHeaderValue(IDictionary parameters) - { - this.parameters = parameters; - } - - public IEnumerable Keys => parameters.Keys; - - public string GetParameter(string key, string name) - { - if (!parameters.ContainsKey(key)) - { - throw new ArgumentException($"Could not find parameter named {key}", nameof(key)); - } - - return GetParameters(key).Single(p => p.Name == name).Value; - } - - public IEnumerable GetParameters(string key) - { - return parameters[key]; - } - } -} diff --git a/src/SpeakEasy/RequestRunner.cs b/src/SpeakEasy/RequestRunner.cs index 0afa475..8d54739 100644 --- a/src/SpeakEasy/RequestRunner.cs +++ b/src/SpeakEasy/RequestRunner.cs @@ -8,7 +8,7 @@ namespace SpeakEasy { using SystemHttpClient = System.Net.Http.HttpClient; - public class RequestRunner : IRequestRunner + internal class RequestRunner : IRequestRunner { private readonly Func> middlewareHead; diff --git a/src/SpeakEasy/TransmissionSettings.cs b/src/SpeakEasy/TransmissionSettings.cs index 2e8c898..7586b44 100644 --- a/src/SpeakEasy/TransmissionSettings.cs +++ b/src/SpeakEasy/TransmissionSettings.cs @@ -7,7 +7,7 @@ namespace SpeakEasy { - public class TransmissionSettings : ITransmissionSettings + internal class TransmissionSettings : ITransmissionSettings { private readonly IEnumerable serializers;