Skip to content

net/http: parse and ignore chunked encoding's chunk-extension  #13135

@uaalto

Description

@uaalto

The server:

package main

import (
  "fmt"
  "io"
  "net/http"
  "net/http/httputil"
)

func hello(w http.ResponseWriter, r *http.Request) {
  dump, _ := httputil.DumpRequest(r, true)
  fmt.Println(dump)
  io.WriteString(w, "Hello world!")
}

func main() {
  http.HandleFunc("/a", hello)
  http.ListenAndServe(":8000", nil)
}

HTTP request:

POST http://localhost:8080/a HTTP/1.1
Transfer-Encoding: chunked
Host: 209.169.10.134:8080
Connection: close


0; name=value

More information

  • The localhost host is irrelevant. Using the server address triggers it too.
  • It's triggered by DumpRequest, but that is just for the test case. Reading the request Body completely triggers it too.
  • It is probably due to the chunk extension. The Go HTTP server corrupts bodies that use it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions