golang version: go1.18.3 linux/amd64 gin version: v1.8.1 nodejs version: 16.15.1 vue version: 2.6.12 axios version: 0.24.0

I set up some response headers like this: ctx.Writer.Header().Set("SM-Encrypted", "true") ctx.Writer.Header().Set("SM-Timestamp", timestamp) ctx.Writer.Header().Set("SM-Key", key) ctx.Writer.Header().Set("SM-Check-Code", checkCode)

However, the key of the response header on the chrome console print results is all lowercase: connection: close content-length: 299 content-type: application/json; charset=utf-8 date: Fri, 04 Nov 2022 03:19:23 GMT sm-check-code: 7ff15cd19ce8e390e4b3b5927b5e8a3c94323cc28dbab70d9c327a47e1a79c4e sm-encrypted: true sm-key: 0123456789abcdef sm-timestamp: 1667531963217 X-Powered-By: Express

Is this correct?I want to return the same result as I set. What do I need to do?

Comment From: liuliqiang

  • go version: go version go1.18.7 darwin/amd64
  • gin version: github.com/gin-gonic/gin v1.8.1

with codes:

func ginMain() {
    router := gin.Default()
    router.GET("/", func(c *gin.Context) {
        c.Writer.Header().Set("SM-Encrypted", "true")
        c.Writer.Header().Set("SM-Timestamp", "1")
        c.JSON(http.StatusOK, map[string]string{})
    })
    http.ListenAndServe(":8080", router)
}

seems can't reproduce:

Gin The key of the response header is changed to lowercase, how to keep the response same as set

And From the content you provided, seems like this response came from Express as there has a header: X-Powered-By: Express.

Comment From: Cookiery

Sorry, I don't reproduce you question too. Maybe it happend in other way.