We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Transfer-Encoding: chunked
Bind fails when Transfer-Encoding: chunked is used.
package main import ( "fmt" "net/http" "net/http/httputil" "github.com/labstack/echo/v4" ) type User struct { Name string `json:"name"` Email string `json:"email"` } func main() { e := echo.New() e.POST("/", func(c echo.Context) error { req := c.Request() fmt.Println("----------") fmt.Println("ContentLength:", req.ContentLength) fmt.Println("TransferEncoding:", req.TransferEncoding) fmt.Println("----------") reqDump, err := httputil.DumpRequest(req, true) if err != nil { return err } fmt.Println(string(reqDump)) var u User if err := c.Bind(&u); err != nil { return err } return c.JSON(http.StatusOK, u) }) e.Logger.Fatal(e.Start(":1323")) }
---------- ContentLength: -1 TransferEncoding: [chunked] ---------- POST / HTTP/1.1 Host: localhost:1323 Transfer-Encoding: chunked Accept-Encoding: gzip Content-Type: application/json User-Agent: Go-http-client/1.1 28 {"name":"foo","email":"foo@example.com"} 0
package main import ( "bytes" "fmt" "io" "log" "net/http" "net/http/httputil" ) func main() { req, err := http.NewRequest("POST", "http://localhost:1323", bytes.NewBufferString(`{"name":"foo","email":"foo@example.com"}`)) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", "application/json") req.ContentLength = 0 reqDump, err := httputil.DumpRequest(req, true) if err != nil { log.Fatal(err) } fmt.Println(string(reqDump)) resp, err := http.DefaultClient.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() b, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } fmt.Println("----------") fmt.Println(string(b)) }
POST / HTTP/1.1 Host: localhost:1323 Content-Type: application/json {"name":"foo","email":"foo@example.com"} ---------- {"name":"","email":""}
v4.13.0
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Issue Description
Bind fails when
Transfer-Encoding: chunked
is used.Working code to debug
Server
Log
Client
Log
Version/commit
v4.13.0
The text was updated successfully, but these errors were encountered: