Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tmenier/Flurl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: Flurl.Http.4.0.2
Choose a base ref
...
head repository: tmenier/Flurl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dev
Choose a head ref
  • 17 commits
  • 10 files changed
  • 4 contributors

Commits on Aug 2, 2024

  1. Copy the full SHA
    6f74a08 View commit details
  2. httpbingo throwing 402 errors

    fortunately httpbin fixed the bug that required me to switch in the first place!
    Todd committed Aug 2, 2024
    Copy the full SHA
    b8645eb View commit details
  3. some test upgrades & fixes

    Todd committed Aug 2, 2024
    Copy the full SHA
    221ce35 View commit details
  4. #823 detect Blazor w/o try/catch

    Todd committed Aug 2, 2024
    Copy the full SHA
    1bb423a View commit details
  5. Copy the full SHA
    4f28752 View commit details

Commits on Sep 11, 2024

  1. Merge pull request #833 from Prologh/dev

    Fix incorrect XML doc about default JSON serializer
    tmenier authored Sep 11, 2024
    Copy the full SHA
    da6121b View commit details

Commits on Oct 10, 2024

  1. Update FlurlClientCache.cs

    Tiny typo that I just noticed when migrating from 3.x and away from FlurlClientFactoryBase.
    Apologies if I misunderstood and that's actually not a typo
    Pyrobolser authored Oct 10, 2024
    Copy the full SHA
    af02ad9 View commit details

Commits on Oct 16, 2024

  1. Merge pull request #844 from Pyrobolser/patch-1

    Change error message in FlurlClientCache.Get if client exists but disposed
    tmenier authored Oct 16, 2024
    Copy the full SHA
    93f5668 View commit details

Commits on Dec 31, 2024

  1. STJ update (vulnerability)

    Todd committed Dec 31, 2024
    Copy the full SHA
    360c15d View commit details
  2. Copy the full SHA
    5c0cbd2 View commit details
  3. Copy the full SHA
    0bf3b83 View commit details
  4. run .NET Framework tests on windows

    ubuntu image no longer comes with mono pre-installed. installing it is easy, but running .NET Framework tests on windows in parallel is probably faster
    tmenier authored Dec 31, 2024
    Copy the full SHA
    f4f549d View commit details
  5. Copy the full SHA
    7e0ac6d View commit details
  6. Copy the full SHA
    52d02ac View commit details

Commits on Jan 1, 2025

  1. Copy the full SHA
    c62605b View commit details
  2. CI - improved readability

    tmenier authored Jan 1, 2025
    Copy the full SHA
    aa7bd45 View commit details
  3. happy new year!

    Todd committed Jan 1, 2025
    Copy the full SHA
    36a3fa2 View commit details
46 changes: 33 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -7,23 +7,43 @@ on:
branches: ["dev", "master"]
workflow_dispatch: # manual trigger

env:
DOTNET_ARGS: >
-c Release
/p:CollectCoverage=true
/p:Threshold=80
/p:Include="[Flurl]*%2C[Flurl.Http]*%2C[Flurl.Http.Newtonsoft]*"
/p:Exclude="[*]*.GeneratedExtensions"
jobs:
build_test:
build-test-ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore

- name: Restore dependencies
run: dotnet restore
- name: Test
run: dotnet test --framework net6.0 $DOTNET_ARGS

build-test-windows:
runs-on: windows-latest
strategy:
matrix:
framework: [net481, net461]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build
run: dotnet build -c Release --no-restore
- name: Restore dependencies
run: dotnet restore

- name: Test
run: dotnet test --no-build -c Release /p:CollectCoverage=true /p:Threshold=80 /p:Include=\"[Flurl]*,[Flurl.Http]*,[Flurl.Http.Newtonsoft]*\" /p:Exclude="[*]*.GeneratedExtensions"
- name: Test
run: dotnet test --framework ${{ matrix.framework }} $DOTNET_ARGS
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Todd Menier
Copyright (c) 2025 Todd Menier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
2 changes: 1 addition & 1 deletion src/Flurl.Http.Newtonsoft/Flurl.Http.Newtonsoft.csproj
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<Version>0.9.1</Version>
<Authors>Todd Menier</Authors>
<Description>A Newtonsoft-based JSON serializer for Flurl.Http 4.0 and above.</Description>
<Copyright>Copyright (c) Todd Menier 2024.</Copyright>
<Copyright>Copyright (c) Todd Menier 2025.</Copyright>
<PackageProjectUrl>https://flurl.dev</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/tmenier/Flurl.git</RepositoryUrl>
2 changes: 1 addition & 1 deletion src/Flurl.Http/Configuration/FlurlClientCache.cs
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ public virtual IFlurlClient Get(string name) {
throw new ArgumentException($"A client named '{name}' was not found. Either preconfigure the client using Add (typically at startup), or use GetOrAdd to add/configure one on demand when needed.");

if (cli.Value.IsDisposed)
throw new Exception($"A client named '{name}' was not found but has been disposed and cannot be reused.");
throw new Exception($"A client named '{name}' was found but has been disposed and cannot be reused.");

return cli.Value;
}
15 changes: 13 additions & 2 deletions src/Flurl.Http/Configuration/FlurlClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Net;
using System.Net.Http;
using System.Runtime.InteropServices;

namespace Flurl.Http.Configuration
{
@@ -41,6 +42,14 @@ public static class FlurlClientFactoryExtensions
/// </summary>
public class DefaultFlurlClientFactory : IFlurlClientFactory
{
// cached Blazor/WASM check (#543, #823)
private readonly bool _isBrowser =
#if NET
OperatingSystem.IsBrowser();
#else
false;
#endif

/// <inheritdoc />
public virtual HttpClient CreateHttpClient(HttpMessageHandler handler) {
return new HttpClient(handler);
@@ -61,8 +70,10 @@ public virtual HttpMessageHandler CreateInnerHandler() {
if (handler.SupportsAutomaticDecompression)
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

try { handler.UseCookies = false; }
catch (PlatformNotSupportedException) { } // look out for WASM platforms (#543)
if (!_isBrowser) {
try { handler.UseCookies = false; }
catch (PlatformNotSupportedException) { } // already checked for Blazor, but just in case any other surprises pop up
}

return handler;
}
2 changes: 1 addition & 1 deletion src/Flurl.Http/Configuration/FlurlHttpSettings.cs
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ public string AllowedHttpStatusRange {
}

/// <summary>
/// Gets or sets object used to serialize and deserialize JSON. Default implementation uses Newtonsoft Json.NET.
/// Gets or sets object used to serialize and deserialize JSON. Default implementation uses System.Text.Json.
/// </summary>
public ISerializer JsonSerializer {
get => Get<ISerializer>();
6 changes: 3 additions & 3 deletions src/Flurl.Http/Flurl.Http.csproj
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<Version>4.0.2</Version>
<Authors>Todd Menier</Authors>
<Description>A fluent, testable HTTP client library.</Description>
<Copyright>Copyright (c) Todd Menier 2024.</Copyright>
<Copyright>Copyright (c) Todd Menier 2025.</Copyright>
<PackageProjectUrl>https://flurl.dev</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
@@ -35,11 +35,11 @@

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
<PackageReference Include="System.Text.Json" Version="6.0.4" />
<PackageReference Include="System.Text.Json" Version="6.0.10" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<Reference Include="System.Net.Http" />
<PackageReference Include="System.Text.Json" Version="6.0.4" />
<PackageReference Include="System.Text.Json" Version="6.0.10" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Flurl/Flurl.csproj
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<Version>4.0.0</Version>
<Authors>Todd Menier</Authors>
<Description>A fluent, portable URL builder. To make HTTP calls off the fluent chain, check out Flurl.Http.</Description>
<Copyright>Copyright (c) Todd Menier 2024.</Copyright>
<Copyright>Copyright (c) Todd Menier 2025.</Copyright>
<PackageProjectUrl>https://flurl.dev</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/tmenier/Flurl.git</RepositoryUrl>
4 changes: 2 additions & 2 deletions test/Flurl.Test/Flurl.Test.csproj
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />

<!--careful - 4.4 and above don't support net461-->
<!--https://docs.nunit.org/articles/vs-test-adapter/AdapterV4-Release-Notes.html-->
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.2" />
</ItemGroup>

<ItemGroup>
21 changes: 11 additions & 10 deletions test/Flurl.Test/Http/RealHttpTests.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;
@@ -19,14 +20,15 @@ namespace Flurl.Test.Http
public class RealHttpTests
{
[TestCase("gzip", "gzipped")]
[TestCase("deflate", "deflated"), Ignore("#474")]
//currently unable to test deflate against httpbin (#474)
//[TestCase("deflate", "deflated")]
public async Task decompresses_automatically(string encoding, string jsonKey) {
var result = await "https://httpbin.org"
.AppendPathSegment(encoding)
.WithHeader("Accept-encoding", encoding)
.GetJsonAsync<Dictionary<string, object>>();
.GetJsonAsync<JsonObject>();

Assert.AreEqual(true, result[jsonKey]);
Assert.AreEqual(true, (bool)result[jsonKey]);
}

[TestCase("https://httpbin.org/image/jpeg", null, "my-image.jpg", "my-image.jpg")]
@@ -243,7 +245,7 @@ public async Task test_settings_override_client_settings() {
using (var test1 = new HttpTest()) {
test1.AllowRealHttp();

var s = await "http://httpbingo.org/redirect-to?url=http%3A%2F%2Fexample.com"
var s = await "http://httpbin.org/redirect-to?url=http%3A%2F%2Fexample.com"
.WithHeader("x", "1")
.GetStringAsync();

@@ -256,7 +258,7 @@ public async Task test_settings_override_client_settings() {
test2.AllowRealHttp();
test2.Settings.Redirects.Enabled = false;

var s = await "http://httpbingo.org/redirect-to?url=http%3A%2F%2Fexample.com"
var s = await "http://httpbin.org/redirect-to?url=http%3A%2F%2Fexample.com"
.WithAutoRedirect(true) // test says redirects are off, and test should always win
.GetStringAsync();

@@ -306,7 +308,7 @@ public async Task does_not_create_empty_content_for_forwarding_content_header()
// Flurl was auto-creating an empty HttpContent object in order to forward content-level headers,
// and on .NET Framework a GET with a non-null HttpContent throws an exceptions (#583)
var calls = new List<FlurlCall>();
var resp = await "http://httpbingo.org/redirect-to?url=http%3A%2F%2Fexample.com%2F"
var resp = await "http://httpbin.org/redirect-to?url=http%3A%2F%2Fexample.com%2F"
.WithSettings(c => c.Redirects.ForwardHeaders = true)
.BeforeCall(call => calls.Add(call))
.PostUrlEncodedAsync("test=test");
@@ -376,13 +378,12 @@ public async Task can_send_different_cookies_per_request() {

[Test]
public async Task can_receive_cookie_from_redirect_response_and_add_it_to_jar() {
// use httpbingo instead of httpbin because of redirect issue https://github.com/postmanlabs/httpbin/issues/617
var resp = await "https://httpbingo.org/redirect-to"
var resp = await "https://httpbin.org/redirect-to"
.SetQueryParam("url", "/cookies/set?x=foo")
.WithCookies(out var jar)
.GetJsonAsync<Dictionary<string, string>>();
.GetJsonAsync<HttpBinResponse>();

Assert.AreEqual("foo", resp["x"]);
Assert.AreEqual("foo", resp.cookies["x"]);
Assert.AreEqual(1, jar.Count);
}
#endregion