Skip to content

Commit

Permalink
spell checking
Browse files Browse the repository at this point in the history
  • Loading branch information
miegir committed Sep 5, 2023
1 parent b11fce9 commit 3f787dd
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.md]
spelling_languages = en-us
spelling_exclusion_path = ./exclusion.dic
56 changes: 28 additions & 28 deletions Miegir.Extensions.Http.Test/HttpClientConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ public void HttpClientHandlerProxyShouldBeConfigured()
{
var provider = new MockConfigurationProvider();

provider.Set("Http:ProxyUrl", "proxyurl");
provider.Set("Http:ProxyUserName", "proxyname");
provider.Set("Http:ProxyPassword", "proxypass");
provider.Set("Http:ProxyDomain", "proxydomain");
provider.Set("Http:ProxyUrl", "proxy_url");
provider.Set("Http:ProxyUserName", "proxy_name");
provider.Set("Http:ProxyPassword", "proxy_pass");
provider.Set("Http:ProxyDomain", "proxy_domain");

var configuration = new ConfigurationBuilder().Add(provider).Build();

Expand All @@ -331,21 +331,21 @@ public void HttpClientHandlerProxyShouldBeConfigured()
var proxy = handler.Proxy.Should().BeOfType<WebProxy>().Subject;
var credential = proxy.Credentials.Should().BeOfType<NetworkCredential>().Subject;

proxy.Address.Should().Be("http://proxyurl/");
credential.UserName.Should().Be("proxyname");
credential.Password.Should().Be("proxypass");
credential.Domain.Should().Be("proxydomain");
proxy.Address.Should().Be("http://proxy_url/");
credential.UserName.Should().Be("proxy_name");
credential.Password.Should().Be("proxy_pass");
credential.Domain.Should().Be("proxy_domain");
}

[TestMethod]
public void HttpClientHandlerProxyShouldInherit()
{
var provider = new MockConfigurationProvider();

provider.Set("Http:ProxyUrl", "proxyurl");
provider.Set("Http:ProxyUserName", "proxyname");
provider.Set("Http:ProxyPassword", "proxypass");
provider.Set("Http:ProxyDomain", "proxydomain");
provider.Set("Http:ProxyUrl", "proxy_url");
provider.Set("Http:ProxyUserName", "proxy_name");
provider.Set("Http:ProxyPassword", "proxy_pass");
provider.Set("Http:ProxyDomain", "proxy_domain");

var configuration = new ConfigurationBuilder().Add(provider).Build();

Expand All @@ -360,23 +360,23 @@ public void HttpClientHandlerProxyShouldInherit()
var proxy = handler.Proxy.Should().BeOfType<WebProxy>().Subject;
var credential = proxy.Credentials.Should().BeOfType<NetworkCredential>().Subject;

proxy.Address.Should().Be("http://proxyurl/");
credential.UserName.Should().Be("proxyname");
credential.Password.Should().Be("proxypass");
credential.Domain.Should().Be("proxydomain");
proxy.Address.Should().Be("http://proxy_url/");
credential.UserName.Should().Be("proxy_name");
credential.Password.Should().Be("proxy_pass");
credential.Domain.Should().Be("proxy_domain");
}

[TestMethod]
public void HttpClientHandlerProxyShouldOverride()
{
var provider = new MockConfigurationProvider();

provider.Set("Http:ProxyUrl", "proxyurl");
provider.Set("Http:ProxyUserName", "proxyname");
provider.Set("Http:ProxyPassword", "proxypass");
provider.Set("Http:ProxyDomain", "proxydomain");
provider.Set("Http:Named:ProxyUrl", "namedproxyurl");
provider.Set("Http:Named:ProxyUserName", "namedproxyname");
provider.Set("Http:ProxyUrl", "proxy_url");
provider.Set("Http:ProxyUserName", "proxy_name");
provider.Set("Http:ProxyPassword", "proxy_pass");
provider.Set("Http:ProxyDomain", "proxy_domain");
provider.Set("Http:Named:ProxyUrl", "named_proxy_url");
provider.Set("Http:Named:ProxyUserName", "named_proxy_name");

var configuration = new ConfigurationBuilder().Add(provider).Build();

Expand All @@ -391,8 +391,8 @@ public void HttpClientHandlerProxyShouldOverride()
var proxy = handler.Proxy.Should().BeOfType<WebProxy>().Subject;
var credential = proxy.Credentials.Should().BeOfType<NetworkCredential>().Subject;

proxy.Address.Should().Be("http://namedproxyurl/");
credential.UserName.Should().Be("namedproxyname");
proxy.Address.Should().Be("http://named_proxy_url/");
credential.UserName.Should().Be("named_proxy_name");
credential.Password.Should().BeEmpty();
credential.Domain.Should().BeEmpty();
}
Expand All @@ -402,10 +402,10 @@ public void HttpClientHandlerProxyShouldNotInheritWhenBaseAddressIsOverridden()
{
var provider = new MockConfigurationProvider();

provider.Set("Http:ProxyUrl", "proxyurl");
provider.Set("Http:ProxyUserName", "proxyname");
provider.Set("Http:ProxyPassword", "proxypass");
provider.Set("Http:ProxyDomain", "proxydomain");
provider.Set("Http:ProxyUrl", "proxy_url");
provider.Set("Http:ProxyUserName", "proxy_name");
provider.Set("Http:ProxyPassword", "proxy_pass");
provider.Set("Http:ProxyDomain", "proxy_domain");
provider.Set("Http:Named:BaseAddress", "https://www.domain.com/");

var configuration = new ConfigurationBuilder().Add(provider).Build();
Expand Down
2 changes: 1 addition & 1 deletion Miegir.Extensions.Http/HttpClientConfigurationInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void ApplyConfiguration(IConfiguration configuration)
}
}

public void ThowBaseAddressShouldNotBeNull()
public void ThrowBaseAddressShouldNotBeNull()
{
var message = $"{DisplayName}: {nameof(BaseAddress)} should not be null.";
throw new OptionsValidationException(
Expand Down
2 changes: 1 addition & 1 deletion Miegir.Extensions.Http/HttpClientConfigurationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Microsoft.Extensions.Http
{
/// <summary>
/// An options class for configuring the <see cref="IHttpClientFactory"/> confuguration.
/// An options class for configuring the <see cref="IHttpClientFactory"/> configuration.
/// </summary>
public class HttpClientConfigurationOptions
{
Expand Down
2 changes: 1 addition & 1 deletion Miegir.Extensions.Http/Miegir.Extensions.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ builder.Services.AddHttpClientConfiguration(options =>
});
```

We can configure our clients manually. The confugiration from `IConfiguration` instance will be provided on top of that (since it is applied with IPostConfigureOptions&lt;HttpClientFactgoryOptions>).
We can configure our clients manually. The configuration from `IConfiguration` instance will be provided on top of that (since it is applied with IPostConfigureOptions&lt;HttpClientFactoryOptions>).
```C#
builder.Services.AddHttpClientConfiguration();

Expand Down Expand Up @@ -73,7 +73,7 @@ The following properties of the HttpClient can be configured:

The following properties of the underlying HttpClientHandler can be configured:
- AllowAutoRedirect.
- Proxy. This is configured using `ProxyUrl` configuration option. If `ProxyUrl` is not empty, the `WebProxy` instance will be created with this url. The `WebProxy.Credentials` property is initialized to `NetworkCredential` instance with the following proepties read from options:
- Proxy. This is configured using `ProxyUrl` configuration option. If `ProxyUrl` is not empty, a `WebProxy` instance will be created with this url. The `WebProxy.Credentials` property is initialized to `NetworkCredential` instance with the following properties read from options:
- UserName. Will be read from `ProxyUserName`.
- Password. Will be read from `ProxyPassword`.
- Domain. Will be read from `ProxyDomain`.
Expand Down Expand Up @@ -103,7 +103,7 @@ With this configuration, the unnamed `HttpClient` will have the `BaseAddress` eq

The proxy for an `HttpClientHandler` will be inherited as long as `BaseAddress` is not overridden. When `BaseAddress` is overridden (even if the same as its parent), the proxy is no longer inherited and should be specified explicitly.

Consider the following confgiuration:
Consider the following configuration:
```json
{
"Http": {
Expand All @@ -129,7 +129,7 @@ Http clients named `"A"` and `"A:B:C"` will not have a proxy, but clients named

When `BaseAddress` is applied from `IConfiguration` instance, the following rules are checked:
- The address should be absolute. Relative `Uri` cannot be assigned to `HttpClient.BaseAddress` anyway.
- `AbsolutePath` of the address should end with `'/'`. This ensures that confiured address will be used exactly as specified when making requests. For example, if the base address would be specified as `"https://domain/root/path"` (not ending with `'/'`) then when performing `httpClient.GetAsync("address")` the request will be made to `"https://domain/root/address"` and not to `"https://domain/root/path/address"` as one might expect. We therefore prohibit paths not ending with `'/'`. This rule is not enforced when `HttpClient` is configured in code.
- `AbsolutePath` of the address should end with `'/'`. This ensures that configured address will be used exactly as specified when making requests. For example, if the base address would be specified as `"https://domain/root/path"` (not ending with `'/'`) then when performing `httpClient.GetAsync("address")` the request will be made to `"https://domain/root/address"` and not to `"https://domain/root/path/address"` as one might expect. We therefore prohibit paths not ending with `'/'`. This rule is not enforced when `HttpClient` is configured in code.

## DefaultRequestHeaders

Expand Down
2 changes: 2 additions & 0 deletions exclusion.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
appsettings
json

0 comments on commit 3f787dd

Please sign in to comment.