Skip to content

add SslProtocolVersion and HttpVersion#53

Merged
MatteoDelOmbra merged 4 commits intomainfrom
FSPES-114
May 6, 2026
Merged

add SslProtocolVersion and HttpVersion#53
MatteoDelOmbra merged 4 commits intomainfrom
FSPES-114

Conversation

@MichalFrends1
Copy link
Copy Markdown
Contributor

@MichalFrends1 MichalFrends1 commented May 5, 2026

Please review my changes :)

Task Update PR template

Review Checklist

  • Task version updated (x.x.0)
  • CHANGELOG.md updated
  • Solution builds
  • Warnings resolved (if possible)
  • Typos resolved
  • Tests cover new code
  • Description how to run tests locally added to README.md (if needed)
  • All tests pass locally

Summary by CodeRabbit

  • New Features

    • Choose TLS protocol: TLS 1.2, TLS 1.3, or both.
    • Choose HTTP protocol: HTTP/1.1 or HTTP/2.
  • Tests

    • Added unit test coverage for protocol version configurations.
  • Chores

    • Package version bumped to 1.10.0 and changelog updated to document the new options.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Walkthrough

Adds protocol selection: new enums SslVersion and HttpVersion, two Options properties (SslProtocolVersion, HttpProtocolVersion), wiring in Extensions.cs to apply them to the handler/client, cache-key update to include the options, a unit test, package bumped to 1.10.0, and changelog entry.

Changes

Protocol Version Configuration

Layer / File(s) Summary
Data Definitions
Frends.HTTP.Request/.../Definitions/SslVersion.cs, Frends.HTTP.Request/.../Definitions/HttpVersion.cs
Add SslVersion enum (Default, Tls12, Tls13, Tls12And13) and HttpVersion enum (Http11, Http20) with XML docs.
Configuration Options
Frends.HTTP.Request/.../Definitions/Options.cs
Add SslProtocolVersion (default SslVersion.Default) and HttpProtocolVersion (default HttpVersion.Http11) properties with DefaultValue attributes.
Handler Settings
Frends.HTTP.Request/.../Extensions.cs
Map options.SslProtocolVersion to handler.SslProtocols (Tls12, Tls13, Tls12
HttpClient Wiring
Frends.HTTP.Request/.../Extensions.cs
Set httpClient.DefaultRequestVersion (HTTP/2 → Version20, else Version11) and DefaultVersionPolicy (exact for HTTP/2, or RequestVersionOrLower otherwise).
Cache Key Update
Frends.HTTP.Request/.../Request.cs
Include SslProtocolVersion and HttpProtocolVersion in GetHttpClientCacheKey to differentiate pooled HttpClient instances.
Tests
Frends.HTTP.Request/.../Frends.HTTP.Request.Tests/UnitTests.cs
Add RequestShouldSetTls12And13WhenConfigured asserting a 200 response with SslProtocolVersion = Tls12And13 and HttpProtocolVersion = Http20.
Version & Changelog
Frends.HTTP.Request/Frends.HTTP.Request.csproj, Frends.HTTP.Request/CHANGELOG.md
Bump package version to 1.10.0. Add [1.10.0] changelog entry (2026-05-05) documenting the two new options.

Sequence Diagram(s)

sequenceDiagram
    actor Caller
    participant HttpClient
    participant Handler
    participant Server
    Caller->>HttpClient: Send request (Options include SslProtocolVersion, HttpProtocolVersion)
    HttpClient->>Handler: Handler enforces SslProtocols and version policy
    Handler->>Server: TLS handshake (Tls1.2 / Tls1.3) and HTTP/2 or HTTP/1.1 negotiated
    Server-->>Handler: Respond
    Handler-->>HttpClient: Return response
    HttpClient-->>Caller: Deliver response (status 200)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Suggested Reviewers

  • jefim

Poem

🐇 I hopped through TLS fields so wide,

TLS12 and 13 now stride side-by-side,
HTTP/2 taps a faster door,
Clients chat with newer lore,
A joyful nibble for code and guide.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding SslProtocolVersion and HttpVersion enums with related configuration options.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch FSPES-114

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
Frends.HTTP.Request/Frends.HTTP.Request/Definitions/HttpVersion.cs (1)

6-16: ⚡ Quick win

HttpVersion conflicts with System.Net.HttpVersion — consider renaming the enum.

The name HttpVersion clashes with the BCL class System.Net.HttpVersion, forcing every file that imports both Frends.HTTP.Request.Definitions and System.Net (or System.Net.Http) to use the fully-qualified form (Definitions.HttpVersion.Http20). This is already visible in Extensions.cs (Line 70) and UnitTests.cs (Line 468).

Renaming the enum to HttpProtocolVersion — which already matches the Options property name — would eliminate the ambiguity entirely.

♻️ Proposed rename
-    public enum HttpVersion
+    public enum HttpProtocolVersion
     {
         /// <summary>
         /// HTTP/1.1 - default, widely supported.
         /// </summary>
         Http11,
         /// <summary>
         /// HTTP/2 - multiplexed, requires server support.
         /// </summary>
         Http20
     }

Then in Options.cs the property type and default already match:

-    [DefaultValue(HttpVersion.Http11)]
-    public HttpVersion HttpProtocolVersion { get; set; } = HttpVersion.Http11;
+    [DefaultValue(HttpProtocolVersion.Http11)]
+    public HttpProtocolVersion HttpProtocolVersion { get; set; } = HttpProtocolVersion.Http11;

And in Extensions.cs the switch arm no longer needs namespace qualification:

-            Definitions.HttpVersion.Http20 => System.Net.HttpVersion.Version20,
+            HttpProtocolVersion.Http20 => System.Net.HttpVersion.Version20,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Frends.HTTP.Request/Frends.HTTP.Request/Definitions/HttpVersion.cs` around
lines 6 - 16, Rename the enum named HttpVersion to HttpProtocolVersion (preserve
the enum members Http11 and Http20 and their XML comments) and update all
references: change the Options class property type (Options.ProtocolVersion or
the existing property that currently uses HttpVersion) to use
HttpProtocolVersion, update the switch in Extensions (remove fully-qualified
System.Net disambiguation) and any usages in UnitTests to the new
HttpProtocolVersion identifier so imports no longer conflict with
System.Net.HttpVersion.
Frends.HTTP.Request/Frends.HTTP.Request.Tests/UnitTests.cs (1)

460-474: ⚡ Quick win

Test conflates TLS and HTTP-version configuration, making failures ambiguous.

The test sets both SslProtocolVersion = Tls12And13 and HttpProtocolVersion = Http20 and then asserts only a 200 status code. This means:

  • A failure could be caused by the Http20 + RequestVersionExact combination (server negotiation) rather than the TLS setting — making it hard to tell which feature regressed.
  • Neither the TLS version actually negotiated nor the HTTP version used is verified; the 200 assertion proves only that the server responded, not that the options were applied.

Consider splitting into two focused tests and, if test isolation is a priority, capturing the response.Version from the HttpResponseMessage to assert the negotiated protocol.

♻️ Suggested split
-    [TestMethod]
-    public async Task RequestShouldSetTls12And13WhenConfigured()
-    {
-        var input = GetInputParams(url: $"{BasePath}/anything");
-        var options = new Options
-        {
-            ConnectionTimeoutSeconds = 60,
-            SslProtocolVersion = SslVersion.Tls12And13,
-            HttpProtocolVersion = Definitions.HttpVersion.Http20
-        };
-
-        var result = await HTTP.Request(input, options, CancellationToken.None);
-
-        ClassicAssert.AreEqual(200, result.StatusCode);
-    }
+    [TestMethod]
+    public async Task RequestShouldSucceedWithTls12And13Configured()
+    {
+        var input = GetInputParams(url: $"{BasePath}/anything");
+        var options = new Options
+        {
+            ConnectionTimeoutSeconds = 60,
+            SslProtocolVersion = SslVersion.Tls12And13,
+        };
+
+        var result = await HTTP.Request(input, options, CancellationToken.None);
+
+        ClassicAssert.AreEqual(200, result.StatusCode);
+    }
+
+    [TestMethod]
+    public async Task RequestShouldSucceedWithHttp20Configured()
+    {
+        var input = GetInputParams(url: $"{BasePath}/anything");
+        var options = new Options
+        {
+            ConnectionTimeoutSeconds = 60,
+            HttpProtocolVersion = Definitions.HttpVersion.Http20
+        };
+
+        var result = await HTTP.Request(input, options, CancellationToken.None);
+
+        ClassicAssert.AreEqual(200, result.StatusCode);
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Frends.HTTP.Request/Frends.HTTP.Request.Tests/UnitTests.cs` around lines 460
- 474, Split the existing conflated test into two focused tests: keep
RequestShouldSetTls12And13WhenConfigured and remove the HttpProtocolVersion
assignment there (only set Options.SslProtocolVersion = SslVersion.Tls12And13)
and assert the request succeeds and, if available on the result, capture and
assert the negotiated TLS if your HTTP client exposes it; create a separate
RequestShouldUseHttp2WhenConfigured test that sets Options.HttpProtocolVersion =
Definitions.HttpVersion.Http20 (leave SslProtocolVersion default) and assert
both success and that the response version was negotiated by checking the
response message version (e.g. result.ResponseMessage.Version or the equivalent
property on the returned result) so failures clearly indicate which feature
regressed; use HTTP.Request, Options, SslProtocolVersion, HttpProtocolVersion,
result.StatusCode and the response Version property to locate and implement the
changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Frends.HTTP.Request/CHANGELOG.md`:
- Around line 3-9: Update the 1.10.0 changelog entry: move the two bullets that
introduce SslProtocolVersion and HttpProtocolVersion from the "### Fixed"
section into a new or existing "### Added" section (referencing the names
SslProtocolVersion and HttpProtocolVersion), ensure their descriptions remain
unchanged, and remove the trailing empty "- " list item so there are no blank
bullets left under the 1.10.0 entry.

In `@Frends.HTTP.Request/Frends.HTTP.Request/Extensions.cs`:
- Around line 68-73: The code sets httpClient.DefaultVersionPolicy =
HttpVersionPolicy.RequestVersionExact unconditionally which breaks existing
default behavior and causes Http20 to fail fast without fallback; change the
logic in SetDefaultRequestHeadersBasedOnOptions (the block that switches on
options.HttpProtocolVersion and sets httpClient.DefaultRequestVersion) so that
DefaultVersionPolicy is set to RequestVersionExact only when
options.HttpProtocolVersion == Definitions.HttpVersion.Http20, and for the
Http11/default branch either leave DefaultVersionPolicy unset or explicitly set
it to HttpVersionPolicy.RequestVersionOrLower to preserve prior behavior; also
update any XML/doc comments for the Http20 enum member and CHANGELOG to note the
strict no-fallback semantics if desired.

---

Nitpick comments:
In `@Frends.HTTP.Request/Frends.HTTP.Request.Tests/UnitTests.cs`:
- Around line 460-474: Split the existing conflated test into two focused tests:
keep RequestShouldSetTls12And13WhenConfigured and remove the HttpProtocolVersion
assignment there (only set Options.SslProtocolVersion = SslVersion.Tls12And13)
and assert the request succeeds and, if available on the result, capture and
assert the negotiated TLS if your HTTP client exposes it; create a separate
RequestShouldUseHttp2WhenConfigured test that sets Options.HttpProtocolVersion =
Definitions.HttpVersion.Http20 (leave SslProtocolVersion default) and assert
both success and that the response version was negotiated by checking the
response message version (e.g. result.ResponseMessage.Version or the equivalent
property on the returned result) so failures clearly indicate which feature
regressed; use HTTP.Request, Options, SslProtocolVersion, HttpProtocolVersion,
result.StatusCode and the response Version property to locate and implement the
changes.

In `@Frends.HTTP.Request/Frends.HTTP.Request/Definitions/HttpVersion.cs`:
- Around line 6-16: Rename the enum named HttpVersion to HttpProtocolVersion
(preserve the enum members Http11 and Http20 and their XML comments) and update
all references: change the Options class property type (Options.ProtocolVersion
or the existing property that currently uses HttpVersion) to use
HttpProtocolVersion, update the switch in Extensions (remove fully-qualified
System.Net disambiguation) and any usages in UnitTests to the new
HttpProtocolVersion identifier so imports no longer conflict with
System.Net.HttpVersion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4bf11eed-88be-45c7-b421-6ae182c641be

📥 Commits

Reviewing files that changed from the base of the PR and between 1ab0761 and b17bae0.

📒 Files selected for processing (7)
  • Frends.HTTP.Request/CHANGELOG.md
  • Frends.HTTP.Request/Frends.HTTP.Request.Tests/UnitTests.cs
  • Frends.HTTP.Request/Frends.HTTP.Request/Definitions/HttpVersion.cs
  • Frends.HTTP.Request/Frends.HTTP.Request/Definitions/Options.cs
  • Frends.HTTP.Request/Frends.HTTP.Request/Definitions/SslVersion.cs
  • Frends.HTTP.Request/Frends.HTTP.Request/Extensions.cs
  • Frends.HTTP.Request/Frends.HTTP.Request/Frends.HTTP.Request.csproj

Comment thread Frends.HTTP.Request/CHANGELOG.md Outdated
Comment thread Frends.HTTP.Request/Frends.HTTP.Request/Extensions.cs Outdated
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("content-type", "application/json");
httpClient.Timeout = TimeSpan.FromSeconds(Convert.ToDouble(options.ConnectionTimeoutSeconds));

if (options.HttpProtocolVersion == Definitions.HttpVersion.Http20)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets do it same switch approach which youve did for Ssl - as I understand for now You are assuming that Http11 is set by default but that might change in a future and a bug will come back to us

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Frends.HTTP.Request/Frends.HTTP.Request/Request.cs`:
- Around line 257-258: The cache key construction in Request.cs currently
includes options.ThrowExceptionOnErrorResponse even though that flag is only
used later in Request() when processing responses and does not affect
HttpClientHandler/HttpClient creation; remove
options.ThrowExceptionOnErrorResponse from the concatenated cache key string
(leave AutomaticCookieHandling, SslProtocolVersion, and HttpProtocolVersion
intact) so the client cache is not split by this response-only flag, and ensure
any references to Request() and Extensions.cs behavior remain consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a202ef1e-7bb6-4a8d-b775-493b7013a3c6

📥 Commits

Reviewing files that changed from the base of the PR and between 721a551 and d74a35c.

📒 Files selected for processing (1)
  • Frends.HTTP.Request/Frends.HTTP.Request/Request.cs

Comment thread Frends.HTTP.Request/Frends.HTTP.Request/Request.cs
@MatteoDelOmbra MatteoDelOmbra merged commit 7abf6a4 into main May 6, 2026
7 checks passed
@MatteoDelOmbra MatteoDelOmbra deleted the FSPES-114 branch May 6, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants