-
Notifications
You must be signed in to change notification settings - Fork 311
TestServer should call IHttpContextFactory.Create with valid featureCollection #896
Comments
In RequestState, setting the RequestFeature properties directly with the one from given request. This make it works but I really don't know the implication. |
Yes, we could do that. The only reason it hadn't been done that way was that it was more convenient to set fields via the HttpContext. See Hosting/src/Microsoft.AspNetCore.TestHost/ClientHandler.cs Lines 128 to 138 in b6da89f
|
In fact, using the feature is also that convenient. Just replacing
with does the trick. QueryString is of different type so .Value will be required for QueryString.FromUriComponent At the end,
may be replace with
|
Hi,
I'm trying to set the TraceIdentifier from request headers early in the request processing before HostingApplication begins the scope and logs it.
To do so, I’m reading HttpContext.Request.Headers in a custom HttpContextFactory.Create method. While it works with Kestrel, it doesn't with TestServer.
From what I understand, TestServer do not populate HttpContext from the IFeatureCollection but it calls IHttpApplication.CreateContext with a fake RequestFeature and modify the returned HttpContext before calling IHttpApplication.ProcessRequestAsync.
If that's not a bug, what is the correct usage and how could I achieve my requirement
The text was updated successfully, but these errors were encountered: