Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Rename response.HeadersSent to response.HasStarted #320

Closed
Tratcher opened this issue May 29, 2015 · 2 comments
Closed

Rename response.HeadersSent to response.HasStarted #320

Tratcher opened this issue May 29, 2015 · 2 comments

Comments

@Tratcher
Copy link
Member

On IHttpResponseFeature and HttpResponse there is a HeadersSent property. The name is somewhat misleading though. 1. It's not just the headers, the status code and reason phrase are also sent, and 2. for Helios (and soon WebListener) there is write-behind buffering such that the response is not actually sent, but the status code and headers can no longer be modified.

Proposal: Rename HeadersSent to HasStarted, e.g. context.Response.HasStarted.

Here's the current flow:

  • First Write/Flush
  • Fire OnSendingHeaders
  • Set HasStarted = true
  • Make the response StatusCode, ReasonPhrase, and Headers read-only
  • Send (or write-behind buffer) the Write.

Related: Should OnSendingHeaders similarly be renamed to OnResponseStarting or OnStarting? Compare to the OnResponseCompleted event.

@davidfowl
Copy link
Member

OnResponseStarted, OnResponseCompleted

/cc @lodejard @muratg This looks like something we'd want to do for beta 6

@Tratcher
Copy link
Member Author

Tratcher commented Jun 5, 2015

I recommend OnResponseStarting over Started as this event is your last chance to make modifications. Once it HasStarted the response fields become read-only. Note that before it was OnSendingHeaders, not OnHeadersSent.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants