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

Transparent decompression for gzip, deflate, etc? #3918

Open
skandragon opened this issue Apr 6, 2024 · 1 comment
Open

Transparent decompression for gzip, deflate, etc? #3918

skandragon opened this issue Apr 6, 2024 · 1 comment

Comments

@skandragon
Copy link

Description

I expected gzip and deflate and other types to be automatically handed, for some reason, or at least have a common middleware that would handle this. Is this not the case?

How to reproduce

package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	g := gin.Default()
	g.POST("/json", func(c *gin.Context) {
		var messages []string
		if err := c.ShouldBindJSON(&messages); err != nil {
			c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
                        return
                }

	})
	g.Run(":9000")
}

And now send it compressed requests.

Expectations

I should be able to send compressed data and have it automatically uncompressed.

Actual result

Environment

  • go version: 1.22.2
  • gin version (or commit ref): github.com/gin-gonic/gin v1.9.1
  • operating system: linux, Darwin
@RedCrazyGhost
Copy link
Contributor

RedCrazyGhost commented Apr 8, 2024

This requires you to handle the client-side and server-side code yourself.
The data has been compressed during network transmission.
This issue can be moved to https://github.com/gin-gonic/contrib for questioning
https://github.com/rickb777/servefiles Maybe this is to want you.

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

2 participants