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

Mishandling 404? #98

Open
rymurr opened this issue Jan 23, 2025 · 3 comments
Open

Mishandling 404? #98

rymurr opened this issue Jan 23, 2025 · 3 comments

Comments

@rymurr
Copy link

rymurr commented Jan 23, 2025

I have a simple program

package main

import (

	"github.com/gin-contrib/gzip"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.New()
	r.Use( gzip.Gzip(gzip.DefaultCompression))

	r.GET("/x", func(c *gin.Context) {
		c.JSON(200, gin.H{"hello": "world"})
	})
	r.Run()
}

when i do curl localhost:8080 -H 'accept-encoding: gzip' -v I get a 200 response and when I do curl localhost:8080 -v I get a 404 response.

I am not sure what I am doing wrong but it seems like the gzip buffer is being closed before gin writes its 404 which somehow messes up the eventual response object.

hitting the localhost:8080/x endpoint works fine

@rymurr
Copy link
Author

rymurr commented Jan 23, 2025

It looks like this was introduced between v1.0.1 and v1.1.0

@cloudberrystory
Copy link

Same stuff

@Kerguillec
Copy link

Hello, same here
Also with debug mode I got the following error with a 200 answer instead of 404 while hitting bad route (since v1.10) :
[GIN-debug] cannot write message to writer during serve error: flate: closed writer
I don't know if it's related

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