Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some missing APIs for HttpContext, HttpRequest and HttpResponse #91

Closed
18 of 38 tasks
Maples7 opened this issue Jul 7, 2022 · 4 comments
Closed
18 of 38 tasks
Assignees
Milestone

Comments

@Maples7
Copy link
Contributor

Maples7 commented Jul 7, 2022

Summary

Most primary APIs of HttpContext, HttpRequest and HttpResponse are provided, which is fantastic! And some missing APIs could be considered to be added to make this adapter more universal.

Motivation and goals

Some missing APIs are frequently used for .NET Framework and adding them to the adapter will make the migration smoother and more doable for large projects.

In scope

For HttpContext:

For HttpRequest:

For HttpResponse:

Risks / unknowns

I can imagine not all of them make sense for ASP.NET Core, or fit .NET Core's design philosophy, or are easy to implement.

Examples

More APIs covered, more large projects could be benefited.

@twsouthwick
Copy link
Member

twsouthwick commented Jul 7, 2022

After looking into these APIs, some are definitely doable while others are on the harder side and some others are probably not something we can really mimic.

HttpContext

We should probably do:

The following are very much tied to IIS. ASP.NET Core does not have a concept of handlers, the SkipAuthorization is tied to IIS authorization, and the SetSessionStateBehavior would only be used in IHttpModules I think

HttpRequest

We should probably do:

  • AcceptTypes
  • FilePath
  • Files
  • Item[String]
  • Params
  • PathInfo
  • ReadEntityBodyMode
  • SaveAs

These may be harder, but possible:

  • RequestContext
  • ClientCertificate
  • PhysicalPath (this doesn't seem to map well with the abstracted file structure of core, but maybe there's an equivalent)

HttpResponse

We should probably do:

  • AppendCookie
  • BinaryWrite
  • ClearHeaders
  • IsRequestBeingRedirected
  • RedirectPermanent
  • TransmitFile
  • WriteFile

These may be harder, but possible:

  • AppendToLog
  • ApplyAppPathModifier (appears to be used for cookieless sessions, which probably doesn't apply on core)
  • BufferOutput (we currently require opt in to this with metadata, not sure if/how we should handle this)
  • SubStatusCode (this is not transmitted to the client, but does end up in logs. This would require a change to the hosting module here to pass a substatus through)
  • Expires (this would require HttpCachePolicy infrastructure to enable)
  • SuppressFormsAuthenticationRedirect (this is a property that the FormsAuthenticationModule hooks into to rewrite 401 to 302)
  • WriteSubstitution (this would need some of the HttpCachePolicy infrastructure to handle properly)

@adityamandaleeka
Copy link
Member

Triage: we consider SubStatusCode to be obsolete so we wouldn't enable support for it without a strong business justification.

@adityamandaleeka
Copy link
Member

Let's do a first pass of the "straightforward" ones and then file separate issues for the more involved ones.

@adityamandaleeka adityamandaleeka added this to the preview4 milestone Jul 8, 2022
twsouthwick added a commit that referenced this issue Jul 11, 2022
twsouthwick added a commit that referenced this issue Jul 11, 2022
These APIs are essentially the same, except that they had different memory characteristics. TransmitFile did not buffer, while WriteFile did. On ASP.NET Core, these will just delegate to IHttpResponseBodyFeature.SendFileAsync.

NOTE: This implementation will cause async over sync to be done. We could potentially expose an async API for this on the ASP.NET Core side as a stepping stone if we want.

Part of #91
twsouthwick added a commit that referenced this issue Jul 11, 2022
These APIs are essentially the same, except that they had different memory characteristics. TransmitFile did not buffer, while WriteFile did. On ASP.NET Core, these will just delegate to IHttpResponseBodyFeature.SendFileAsync.

NOTE: This implementation will call Task.GetAwaiter().GetResult(). We could potentially expose an async API for this on the ASP.NET Core side as a stepping stone if we want.

Part of #91
twsouthwick added a commit that referenced this issue Jul 11, 2022
These APIs are essentially the same, except that they had different memory characteristics. TransmitFile did not buffer, while WriteFile did. On ASP.NET Core, these will just delegate to IHttpResponseBodyFeature.SendFileAsync.

NOTE: This implementation will call Task.GetAwaiter().GetResult(). We could potentially expose an async API for this on the ASP.NET Core side as a stepping stone if we want.

Part of #91
twsouthwick added a commit that referenced this issue Jul 11, 2022
twsouthwick added a commit that referenced this issue Jul 11, 2022
These APIs are essentially the same, except that they had different memory characteristics. TransmitFile did not buffer, while WriteFile did. On ASP.NET Core, these will just delegate to IHttpResponseBodyFeature.SendFileAsync.

NOTE: This implementation will call Task.GetAwaiter().GetResult(). We could potentially expose an async API for this on the ASP.NET Core side as a stepping stone if we want.

Part of #91
twsouthwick added a commit that referenced this issue Jul 11, 2022
These APIs are essentially the same, except that they had different memory characteristics. TransmitFile did not buffer, while WriteFile did. On ASP.NET Core, these will just delegate to IHttpResponseBodyFeature.SendFileAsync.

NOTE: This implementation will call Task.GetAwaiter().GetResult(). We could potentially expose an async API for this on the ASP.NET Core side as a stepping stone if we want.

Part of #91
twsouthwick added a commit that referenced this issue Jul 13, 2022
This change adds a few APIs that were missing from HttpResponse.

SubStatusCode is a placeholder for the value, but does not actually publish it anywhere.

TransmitFile/WriteFile: These APIs are essentially the same, except that they had different memory characteristics. TransmitFile did not buffer, while WriteFile did. On ASP.NET Core, these will just delegate to IHttpResponseBodyFeature.SendFileAsync.

NOTE: This implementation will call Task.GetAwaiter() which should be avoided. We could potentially expose an async API for this on the ASP.NET Core side as a stepping stone if we want.

Part of #91
@twsouthwick
Copy link
Member

Issues will be tracked in linked issues, so closing this larger issue.

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

No branches or pull requests

3 participants