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

routesrv: accept gzip encoding #2738

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

AlexanderYastrebov
Copy link
Member

Support gzip encoding to reduce response size.

@szuecs
Copy link
Member

szuecs commented Nov 15, 2023

please create the PR on top of cw2023freeze

@AlexanderYastrebov AlexanderYastrebov changed the base branch from master to cw2023freeze November 15, 2023 13:08
@AlexanderYastrebov AlexanderYastrebov marked this pull request as ready for review November 15, 2023 13:10
w.Header().Set(routing.RoutesCountName, strconv.Itoa(count))

if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") && len(zdata) > 0 {
w.Header().Set("Etag", `"`+hash+`+gzip"`)
Copy link
Member

Choose a reason for hiding this comment

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

maybe use fmt.Sprintf?

Copy link
Member Author

@AlexanderYastrebov AlexanderYastrebov Nov 15, 2023

Choose a reason for hiding this comment

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

yeah, I thought about it but it scatches me to use printf to add quotes

Copy link
Member Author

Choose a reason for hiding this comment

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

w.Header().Set("Etag", `"`+hash+`"`)
w.Header().Set("Etag", `"`+hash+`+gzip"`)
// vs
w.Header().Set("Etag", fmt.Sprintf(`"%s"`, hash))
w.Header().Set("Etag", fmt.Sprintf(`"%s+gzip"`, hash))

Copy link
Member

@MustafaSaber MustafaSaber Nov 15, 2023

Choose a reason for hiding this comment

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

I don't know if %q makes it better

fmt.Sprintf("%q", hash)
fmt.Sprintf("%q", hash+"+gzip")

Copy link
Member

Choose a reason for hiding this comment

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

maybe: fmt.Sprintf("%qgzip", hash)

Copy link
Member

Choose a reason for hiding this comment

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

ah no this does not work https://go.dev/play/p/xy_341u63TE.
I think @AlexanderYastrebov already tried the best one, in case he wants to have a string like:
"...gzip" and not "..."gzip

Support gzip encoding to reduce response size.

Signed-off-by: Alexander Yastrebov <[email protected]>
@szuecs
Copy link
Member

szuecs commented Nov 15, 2023

👍

1 similar comment
@MustafaSaber
Copy link
Member

👍

@AlexanderYastrebov AlexanderYastrebov merged commit a92ff60 into cw2023freeze Nov 16, 2023
9 checks passed
@AlexanderYastrebov AlexanderYastrebov deleted the routesrv/accept-gzip-encoding branch November 16, 2023 13:38
AlexanderYastrebov added a commit that referenced this pull request Nov 27, 2023
Support gzip encoding to reduce response size.

Signed-off-by: Alexander Yastrebov <[email protected]>
AlexanderYastrebov added a commit that referenced this pull request Nov 27, 2023
Support gzip encoding to reduce response size.

Signed-off-by: Alexander Yastrebov <[email protected]>
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.

4 participants