Client http2 support

Does go http client by default supports http2 or do we need special settings for it? I am using Go1.9 .


Starting with Go 1.6, the http package has transparent support for the HTTP/2 protocol when using HTTPS.

Thanks, I am making a post call over the https, that should be fine ?

Here is sample code with http get, it show HTTP1.1


package main

import (

const (
	GOOGLE_TEST_URL       = ""
	CONTENT_TYPE = "text/html"

func executeHTTP2() {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},

	req, err := http.NewRequest("GET", GOOGLE_TEST_URL, nil)

	client := &http.Client{Transport: tr}

	dump, err := httputil.DumpRequest(req, true)
	if err != nil {

	log.Printf("%q", dump)

	resp, err := client.Do(req)

	//resp, err := client.Post(GOOGLE_TEST_URL, CONTENT_TYPE, nil)
	if err != nil {
		log.Println("Error while making https request")

	defer resp.Body.Close()

	_, err = ioutil.ReadAll(resp.Body)
	if err != nil && resp.StatusCode != http.StatusOK {
		log.Println("Failed to parse request boxy")

	log.Println("request success")

func main() {

2018/01/31 09:52:07 "GET /search?q=golang&oq=golang&aqs=chrome…69i57j69i60l2j69i59l3.1966j1j7&ie=UTF-8 HTTP/1.1\r\nHost:\r\n\r\n"
2018/01/31 09:52:08 request success

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.