• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Aldaviva / Unfucked / 19267488260

11 Nov 2025 01:23PM UTC coverage: 47.79% (+0.04%) from 47.751%
19267488260

push

github

Aldaviva
Enable automatic HTTP response body decompression by default

630 of 1655 branches covered (38.07%)

10 of 15 new or added lines in 3 files covered. (66.67%)

78 existing lines in 5 files now uncovered.

1146 of 2398 relevant lines covered (47.79%)

51.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

31.82
/HTTP/Config/ClientConfig.cs
1
using System.Collections.Immutable;
2
using System.Diagnostics.Contracts;
3
using Unfucked.HTTP.Filters;
4
using Unfucked.HTTP.Serialization;
5

6
namespace Unfucked.HTTP.Config;
7

8
public interface IClientConfig: Configurable<IClientConfig>, ICloneable;
9

10
public class ClientConfig: IClientConfig {
11

12
    public const int FIRST_FILTER_POSITION = 0;
13
    public const int LAST_FILTER_POSITION  = int.MaxValue;
14

15
    private ImmutableList<ClientRequestFilter> ReqFilters { get; init; }
11✔
16
    private ImmutableList<ClientResponseFilter> ResFilters { get; init; }
11✔
17
    private ImmutableHashSet<MessageBodyReader> Readers { get; init; }
12✔
18
    private ImmutableDictionary<PropertyKey, object> Properties { get; init; }
13✔
19

20
    [Pure]
21
    public IReadOnlyList<ClientRequestFilter> RequestFilters => ReqFilters.AsReadOnly();
×
22

23
    [Pure]
24
    public IReadOnlyList<ClientResponseFilter> ResponseFilters => ResFilters.AsReadOnly();
×
25

26
    [Pure]
27
    public IEnumerable<MessageBodyReader> MessageBodyReaders => Readers.AsEnumerable();
1✔
28

29
#pragma warning disable IDE0301 // Simplify collection initialization - breaks in .NET 6
30
    internal ClientConfig() {
11✔
31
        ReqFilters = ImmutableList<ClientRequestFilter>.Empty;
11✔
32
        ResFilters = ImmutableList<ClientResponseFilter>.Empty;
11✔
33
        Readers    = ImmutableHashSet<MessageBodyReader>.Empty;
11✔
34
        Properties = ImmutableDictionary<PropertyKey, object>.Empty;
11✔
35
    }
11✔
36
#pragma warning restore IDE0301 // Simplify collection initialization
37

38
    private ClientConfig(ClientConfig other) {
×
39
        ReqFilters = other.ReqFilters;
×
40
        ResFilters = other.ResFilters;
×
41
        Readers    = other.Readers;
×
42
        Properties = other.Properties;
×
43
    }
×
44

45
    /// <inheritdoc />
46
    [Pure]
UNCOV
47
    public object Clone() => new ClientConfig(this);
×
48

49
    /// <inheritdoc />
50
    [Pure]
UNCOV
51
    public IClientConfig Register(Registrable registrable) => registrable switch {
×
UNCOV
52
        MessageBodyReader m    => new ClientConfig(this) { Readers = Readers.Add(m) },
×
53
        ClientRequestFilter r  => Register(r, LAST_FILTER_POSITION),
×
54
        ClientResponseFilter r => Register(r, LAST_FILTER_POSITION),
×
55
        _                      => throw new ArgumentException($"This {nameof(ClientConfig)} class does not have a way to register a {registrable.GetType()}", nameof(registrable))
×
56
    };
×
57

58
    /// <inheritdoc />
59
    [Pure]
UNCOV
60
    public IClientConfig Register<Option>(Registrable<Option> registrable, Option registrationOption) => registrable switch {
×
UNCOV
61
        ClientRequestFilter r when registrationOption is int o => new ClientConfig(this) { ReqFilters = Register(ReqFilters, r, o) },
×
62
        ClientResponseFilter r when registrationOption is int o => new ClientConfig(this) { ResFilters = Register(ResFilters, r, o) },
×
63
        _ => throw new ArgumentException($"This {nameof(ClientConfig)} class does not have a way to register a {registrable.GetType()}", nameof(registrable))
×
64
    };
×
65

66
    private static ImmutableList<T> Register<T>(ImmutableList<T> list, T? newItem, int position) {
UNCOV
67
        int  oldCount  = list.Count;
×
UNCOV
68
        bool isRemoval = newItem is null;
×
69
        position = position switch {
×
70
            < FIRST_FILTER_POSITION                  => 0,
×
71
            _ when position >= oldCount && isRemoval => oldCount - 1,
×
72
            _ when position > oldCount               => oldCount,
×
73
            _                                        => position
×
74
        };
×
75
        return isRemoval ? list.RemoveAt(position) : list.Insert(position, newItem!);
×
76
    }
77

78
    /// <inheritdoc />
79
    [Pure]
80
    public IClientConfig Property<T>(PropertyKey<T> key, T? newValue) where T: notnull =>
UNCOV
81
        new ClientConfig(this) { Properties = newValue is not null ? Properties.SetItem(key, newValue) : Properties.Remove(key) };
×
82

83
    /// <inheritdoc cref="Configurable.Property{T}" />
84
    [Pure]
85
    public bool Property<T>(PropertyKey<T> key,
86
#if !NETSTANDARD2_0
87
                            [NotNullWhen(true)]
88
#endif
89
                            out T? existingValue) where T: notnull {
90
        bool exists = Properties.TryGetValue(key, out object? rawValue);
2✔
91
        existingValue = exists ? (T?) rawValue : default;
2!
92
        return exists;
2✔
93
    }
94

95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc