Skip to content

Commit

Permalink
Merge pull request #84 from martincostello/Fix-Content-Type-For-Bundles
Browse files Browse the repository at this point in the history
Fix content-type for bundles
  • Loading branch information
martincostello authored Apr 28, 2019
2 parents 972d85e + 40390b6 commit 584b416
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function DotNetTest {
$openCoverVersion = "4.7.922"
$openCoverPath = Join-Path $nugetPath "OpenCover\$openCoverVersion\tools\OpenCover.Console.exe"

$reportGeneratorVersion = "4.1.0"
$reportGeneratorVersion = "4.1.4"
$reportGeneratorPath = Join-Path $nugetPath "ReportGenerator\$reportGeneratorVersion\tools\netcoreapp2.0\ReportGenerator.dll"

$coverageOutput = Join-Path $OutputPath "code-coverage.xml"
Expand Down
11 changes: 5 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
<Compile Include="$(MSBuildThisFileDirectory)CommonAssemblyInfo.cs" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" />
<PackageReference Include="OpenCover" Version="4.7.922" PrivateAssets="All" />
<PackageReference Include="ReportGenerator" Version="4.1.0" PrivateAssets="All" />
<PackageReference Include="ReportGenerator" Version="4.1.4" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="All" />
<PackageReference Include="Text.Analyzers" Version="2.6.3" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
Expand All @@ -36,7 +35,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.0.1</VersionPrefix>
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(APPVEYOR)' == 'true' AND '$(APPVEYOR_REPO_TAG)' != 'true'">beta$([System.Convert]::ToInt32(`$(APPVEYOR_BUILD_NUMBER)`).ToString(`0000`))</VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(TF_BUILD)' == 'True'">beta$([System.Convert]::ToInt32(`$(BUILD_BUILDID)`).ToString(`0000`))</VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(TRAVIS)' == 'true'">beta$([System.Convert]::ToInt32(`$(TRAVIS_BUILD_NUMBER)`).ToString(`0000`))</VersionSuffix>
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
os: Visual Studio 2017
version: 2.0.0.{build}
version: 2.0.1.{build}

environment:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.202"
"version": "2.2.203"
}
}
6 changes: 3 additions & 3 deletions samples/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<AspNetCoreHostingModel>inprocess</AspNetCoreHostingModel>
<NoWarn>$(NoWarn);CA2007</NoWarn>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Refit" Version="4.6.99" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Refit" Version="4.6.107" />
</ItemGroup>
</Project>
6 changes: 5 additions & 1 deletion src/HttpClientInterception/HttpClientInterceptorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,11 @@ private static async Task<HttpResponseMessage> BuildResponseAsync(HttpRequestMes

PopulateHeaders(result.Content.Headers, response.ContentHeaders);

result.Content.Headers.ContentType = new MediaTypeHeaderValue(response.ContentMediaType);
// Do not overwrite a custom Content-Type header if already set
if (!result.Content.Headers.TryGetValues("content-type", out var contentType))
{
result.Content.Headers.ContentType = new MediaTypeHeaderValue(response.ContentMediaType);
}

PopulateHeaders(result.Headers, response.ResponseHeaders);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Benchmarks for JustEat.HttpClientInterception</Description>
<NoWarn>$(NoWarn);CA1056;CA2007</NoWarn>
Expand All @@ -15,6 +15,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
<PackageReference Include="Refit" Version="4.6.99" />
<PackageReference Include="Refit" Version="4.6.107" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public static async Task Can_Intercept_Http_Requests_From_Bundle_File()
options.RegisterBundle(Path.Join("Bundles", "http-request-bundle.json"));

// Assert
await HttpAssert.GetAsync(options, "https://www.just-eat.co.uk/");
await HttpAssert.GetAsync(options, "https://www.just-eat.co.uk/", mediaType: "text/html");
await HttpAssert.GetAsync(options, "https://www.just-eat.co.uk/order-history");
await HttpAssert.GetAsync(options, "https://api.github.com/orgs/justeat", headers: headers);
await HttpAssert.GetAsync(options, "https://api.github.com/orgs/justeat", headers: headers, mediaType: "application/json");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.10" />
<PackageReference Include="Refit" Version="4.6.99" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.11" />
<PackageReference Include="Refit" Version="4.6.107" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
Expand Down

0 comments on commit 584b416

Please sign in to comment.