Skip to content
New issue

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

Is http2 supported? #124

Closed
Kliton opened this issue Dec 16, 2016 · 2 comments
Closed

Is http2 supported? #124

Kliton opened this issue Dec 16, 2016 · 2 comments

Comments

@Kliton
Copy link

Kliton commented Dec 16, 2016

Is http 2.0 supported ?'

@sleach
Copy link

sleach commented Dec 30, 2016

Yes, you can test it with:

package main

import (
	"fmt"

	"github.com/parnurzeal/gorequest"
)

func main() {
	url := "https://http2.golang.org/reqinfo"
	request := gorequest.New()
	_, body, errs := request.Get(url).End()
	if len(errs) == 0 {
		fmt.Printf("%s", string(body))
	} else {
		fmt.Printf("ERR: %v\n", errs)
	}
}

which outputs:

Method: GET
Protocol: HTTP/2.0
Host: http2.golang.org
RemoteAddr: XXX.XXX.XXX.XXX:55006
RequestURI: "/reqinfo"
URL: &url.URL{Scheme:"", Opaque:"", User:(*url.Userinfo)(nil), Host:"", Path:"/reqinfo", RawPath:"", ForceQuery:false, RawQuery:"", Fragment:""}
Body.ContentLength: 0 (-1 means unknown)
Close: false (relevant for HTTP/1 only)
...

Headers:
Accept-Encoding: gzip
User-Agent: Go-http-client/2.0

@Kliton Kliton closed this as completed Jan 2, 2017
@gwillem
Copy link

gwillem commented Apr 24, 2017

It will fall back to HTTP/1.1 when you do anything special (such as gorequest.New().Timeout(15 * time.Second)). Background: golang/go#17051

Fix:

import "golang.org/x/net/http2"
s := gorequest.New().Timeout(15 * time.Second)
http2.ConfigureTransport(s.Transport)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants