Skip to content

Fix ResponseHeaderFields.ToString() to emit Connection header from property instead of hardcoding "Upgrade"#12

Merged
ReneSchwarzer merged 2 commits intodevelopfrom
copilot/update-documentation-for-installation
Apr 4, 2026
Merged

Fix ResponseHeaderFields.ToString() to emit Connection header from property instead of hardcoding "Upgrade"#12
ReneSchwarzer merged 2 commits intodevelopfrom
copilot/update-documentation-for-installation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

ResponseHeaderFields.ToString() hardcoded Connection: Upgrade whenever Upgrade was set, making the Connection property effectively unused in HTTP output. This broke any response that set Connection to a value other than "Upgrade", and silently dropped the Connection header for any response that didn't also set Upgrade.

Changes

  • ResponseHeaderFields.cs: Decouple Connection and Upgrade header emission — each is now written independently when its property is non-empty. Connection: Upgrade is no longer hardcoded.

ResponseSwitchingProtocols already explicitly sets Header.Connection = connection, so WebSocket 101 handshakes continue to emit the correct headers without any changes to the caller.

// Before: Connection: Upgrade always hardcoded when Upgrade is set
if (!string.IsNullOrWhiteSpace(Upgrade))
{
    sb.AppendLine("Upgrade: " + Upgrade);
    sb.AppendLine("Connection: Upgrade"); // ignores Connection property
}

// After: each header driven by its own property
if (!string.IsNullOrWhiteSpace(Connection))
    sb.AppendLine("Connection: " + Connection);

if (!string.IsNullOrWhiteSpace(Upgrade))
    sb.AppendLine("Upgrade: " + Upgrade);

…d of hardcoding Connection: Upgrade

Agent-Logs-Url: https://github.com/webexpress-framework/WebExpress.WebCore/sessions/e8d260a2-11b1-4b7a-a8fc-0c154ce33291

Co-authored-by: ReneSchwarzer <31061438+ReneSchwarzer@users.noreply.github.com>
Copilot AI changed the title [WIP] Update installation documentation for clarity Fix ResponseHeaderFields.ToString() to emit Connection header from property instead of hardcoding "Upgrade" Apr 4, 2026
Copilot AI requested a review from ReneSchwarzer April 4, 2026 20:11
@ReneSchwarzer ReneSchwarzer marked this pull request as ready for review April 4, 2026 20:14
@ReneSchwarzer ReneSchwarzer merged commit 10c27cb into develop Apr 4, 2026
1 check passed
@ReneSchwarzer ReneSchwarzer deleted the copilot/update-documentation-for-installation branch April 4, 2026 20:15
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