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

feat: ability to edit status messages #1126

Merged
merged 5 commits into from Oct 22, 2021
Merged

Conversation

valchulen
Copy link
Contributor

@valchulen valchulen commented Oct 13, 2021

I'm in need to change the message associated with the status of a request. In my context: when millions of RPS are answered with 204, every byte of the response counts towards reducing AWS transfer out costs, so "NC" instead of "No Content" is a small change with big impact.

To do so, I've created SetStatusMessage. Also I've extracted the set of the statusLines to reuse it in said function.

I await for you input! Thanks!

Valentin Paz Marcolla added 2 commits October 13, 2021 12:15
Copy link
Collaborator

@erikdubbelboer erikdubbelboer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good idea. I would rather add a statusLine []byte field to ResponseHeader and methods to set it. And when it's set it should be used here, otherwise use the current code:

dst = append(dst, statusLine(statusCode)...)

Copy link
Collaborator

@erikdubbelboer erikdubbelboer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to reset h.statusLine in the Reset method.

header.go Outdated Show resolved Hide resolved
header.go Show resolved Hide resolved
header.go Show resolved Hide resolved
@erikdubbelboer erikdubbelboer merged commit 556aa81 into valyala:master Oct 22, 2021
@erikdubbelboer
Copy link
Collaborator

Thanks!

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.

None yet

4 participants