Skip to content

Analysis: Minimum changes to move server.cs from HttpListener to Kestrel#114

Closed
nagendramishr with Copilot wants to merge 1 commit into
mainfrom
copilot/analyze-kestrel-changes
Closed

Analysis: Minimum changes to move server.cs from HttpListener to Kestrel#114
nagendramishr with Copilot wants to merge 1 commit into
mainfrom
copilot/analyze-kestrel-changes

Conversation

Copilot AI commented Feb 13, 2026

Copy link
Copy Markdown

Report-only analysis of what's required to migrate server.cs from System.Net.HttpListener to Kestrel. No code changes.

Core Finding

The minimum to instantiate a RequestData after Kestrel receives a request is 3 changes:

  1. New constructor on RequestData accepting HttpContext instead of HttpListenerContext
  2. Change Context property type from HttpListenerContext? to HttpContext? (~30+ downstream references)
  3. Property mapping in the new constructor:
public RequestData(HttpContext httpContext, string mid)
{
    Path = httpContext.Request.Path + httpContext.Request.QueryString;
    Method = httpContext.Request.Method;
    Headers = CopyToWebHeaderCollection(httpContext.Request.Headers);
    Body = httpContext.Request.Body;
    OutputStream = httpContext.Response.Body;
}

Ripple Effects

  • Response API changes: .Response.OutputStream.Response.Body, .ContentLength64.ContentLength, remove .Response.Close() calls
  • ProxyWorker.cs: ~15 request.Context references need API updates
  • AsyncWorker.cs: ~7 references for blob URI headers and status codes
  • ProbeServer.cs: 3 methods change signature from HttpListenerContextHttpContext
  • EventDataBuilder.cs: 1 method signature update
  • Project: SDK Microsoft.NET.Sdk.WorkerMicrosoft.NET.Sdk.Web, host builder → WebApplication.CreateBuilder
  • server.cs: Run() accept loop replaced by Kestrel middleware; all enqueue/validation logic unchanged

What Doesn't Change

All request processing logic (header validation, priority assignment, queue enqueue, circuit breaker checks) operates on RequestData fields — not on the HTTP context directly — and requires zero modification.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Analyze minimum changes for Kestrel request instantiation Analysis: Minimum changes to move server.cs from HttpListener to Kestrel Feb 13, 2026
Copilot AI requested a review from nagendramishr February 13, 2026 18:43
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