Skip to content

net/http: http2 negative content length #14003

Closed
@rafaeljusto

Description

@rafaeljusto

Hi,

I was testing Go1.6-beta2 and found a strange behavior with HTTP2. I developed a simple server that only prints the request content-length. When tested with Go1.5 it works fine (content-length greater or equal to zero), but when I submit some content in Go1.6 using HTTP2 (TLS) the server prints -1.

Server:

package main

import (
    "fmt"
    "log"
    "net/http"
)

func main() {
    http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
        fmt.Printf("LENGTH: %d\n", r.ContentLength)
    })

    log.Fatal(http.ListenAndServeTLS(":8080", "cert.pem", "key.pem", nil))
}

Client:

package main

import (
    "crypto/tls"
    "fmt"
    "net/http"
    "strings"
)

func main() {
    client := http.Client{
        Transport: &http.Transport{
            TLSClientConfig: &tls.Config{
                InsecureSkipVerify: true,
            },
        },
    }

    resp, err := client.Post("https://127.0.0.1:8080/bar", "text/plain", strings.NewReader("TEST!"))
    if err != nil {
        fmt.Println(err)
        return
    }
    defer resp.Body.Close()
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions