Skip to content

net/http: HTTP/2 server cannot accept HTTP requests #19755

@rakyll

Description

@rakyll
$ go version
go version devel +54af18708b Wed Mar 29 00:02:06 2017 +0000 darwin/amd64

Consider the following server:

package main

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

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		io.WriteString(w, "hello")
	})
	log.Fatal(http.ListenAndServeTLS("localhost:4444", "server.crt", "server.key", nil))
}

Requests to the server via HTTP is broken and the server logs the following error message:

2017/03/28 17:45:36 http: TLS handshake error from 127.0.0.1:51664: tls: first record does not look like a TLS handshake
curl -v http://localhost:4444
* Rebuilt URL to: http://localhost:4444/
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 4444 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4444 (#0)
> GET / HTTP/1.1
> Host: localhost:4444
> User-Agent: curl/7.51.0
> Accept: */*
>

* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact

/cc @tombergan @bradfitz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions