Skip to content

Add HttpHeadersExtensions with TryGetValue and GetValuesOrEmpty#68

Merged
Tyrrrz merged 8 commits intoprimefrom
copilot/add-discord-chat-exporter-extension
Apr 19, 2026
Merged

Add HttpHeadersExtensions with TryGetValue and GetValuesOrEmpty#68
Tyrrrz merged 8 commits intoprimefrom
copilot/add-discord-chat-exporter-extension

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

Ports HttpExtensions from DiscordChatExporter into PowerKit as HttpHeadersExtensions, extending System.Net.Http.Headers.HttpHeaders.

Changes

  • PowerKit/Extensions/HttpHeadersExtensions.cs — adds two extension methods on HttpHeaders:
    • GetValuesOrEmpty(string name): returns all header values as IEnumerable<string>, or an empty sequence if absent
    • TryGetValue(string name): returns all header values joined with ", " as string, or an empty string if absent; delegates to GetValuesOrEmpty
  • PowerKit.Tests/Extensions/HttpHeadersExtensionsTests.cs — covers found, not found, and multi-value cases for both methods

Usage

string value = response.Headers.TryGetValue("X-Custom-Header");

IEnumerable<string> values = response.Headers.GetValuesOrEmpty("X-Custom-Header");

@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 19, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 19, 2026 07:46
Copilot AI review requested due to automatic review settings April 19, 2026 07:46
Comment thread PowerKit.Tests/Extensions/HttpHeadersExtensionsTests.cs
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.07%. Comparing base (eb22eec) to head (3efdfc2).
⚠️ Report is 6 commits behind head on prime.

Additional details and impacted files
@@            Coverage Diff             @@
##            prime      #68      +/-   ##
==========================================
- Coverage   94.85%   94.07%   -0.79%     
==========================================
  Files         120      128       +8     
  Lines        2333     2496     +163     
  Branches      177      198      +21     
==========================================
+ Hits         2213     2348     +135     
- Misses         86      107      +21     
- Partials       34       41       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread PowerKit/Extensions/HttpHeadersExtensions.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports a header helper into PowerKit by adding an HttpHeaders extension method that attempts to retrieve a header value as a string?, with accompanying unit tests.

Changes:

  • Added HttpHeadersExtensions.TryGetValue(string name) for System.Net.Http.Headers.HttpHeaders
  • Added tests covering present, absent, and multi-value headers

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
PowerKit/Extensions/HttpHeadersExtensions.cs Introduces the HttpHeaders extension method that retrieves header values as a nullable string
PowerKit.Tests/Extensions/HttpHeadersExtensionsTests.cs Adds xUnit coverage for the new extension method’s behaviors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/Extensions/HttpHeadersExtensions.cs Outdated
Comment thread PowerKit/Extensions/HttpHeadersExtensions.cs Outdated
Copilot AI changed the title Add HttpHeadersExtensions with TryGetValue Add HttpHeadersExtensions with TryGetValue and TryGetValues Apr 19, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread PowerKit/Extensions/HttpHeadersExtensions.cs Outdated
Comment thread PowerKit/Extensions/HttpHeadersExtensions.cs Outdated
Comment thread PowerKit/Extensions/HttpHeadersExtensions.cs Outdated
Comment thread PowerKit/Extensions/HttpHeadersExtensions.cs Outdated
…keep TryGetValues name (GetValues conflicts with BCL)

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/25be9da9-ac15-469d-8302-5d7328cc0f44

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot AI changed the title Add HttpHeadersExtensions with TryGetValue and TryGetValues Add HttpHeadersExtensions with TryGetValue and GetValuesOrEmpty Apr 19, 2026
Comment thread PowerKit.Tests/Extensions/HttpHeadersExtensionsTests.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants