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

Redirects with schema changes: Too many redirects detected when doing the request #244

Closed
gabrielperezs opened this issue Mar 26, 2017 · 1 comment

Comments

@gabrielperezs
Copy link
Contributor

For the testing you can use the url http://www.reddit.com/static/button/button1.js, if you do a simple curl to this url will return a 301 code with a new url over https:

HTTP/1.1 301 Moved Permanently
Retry-After: 0
Location: https://www.reddit.com/static/button/button1.js
Content-Length: 0
...

But using the fasthttp.HostClient will return an error "301 too many redirects detected when doing the request"

Code example to reproduce it.

package main

import (
	"fmt"
	"net/url"
	"time"

	"github.com/valyala/fasthttp"
)

var (
	destUrl = "http://www.reddit.com/static/button/button1.js"
)

func main() {

	u, err := url.Parse(destUrl)
	if err != nil {
		fmt.Println(err)
		return
	}

	var reqClient *fasthttp.HostClient
	port := 80

	reqClient = &fasthttp.HostClient{
		Addr: fmt.Sprintf("%s:%d", string(u.Host), port),
	}

	statusCode, body, err := reqClient.GetTimeout(nil, destUrl, 4000*time.Millisecond)
	if err != nil {
		fmt.Println(statusCode, err)
		return
	}

	fmt.Println(statusCode, string(body))
}

Full output of the testing

$ go run testing.go
http://www.reddit.com/static/button/button1.js
301 too many redirects detected when doing the request
gabrielperezs added a commit to gabrielperezs/fasthttp that referenced this issue Mar 26, 2017
gabrielperezs added a commit to gabrielperezs/fasthttp that referenced this issue Mar 30, 2017
The test code create two servers. One with TLS and the other
without. The a client will send a request to the http and will
receive an 301 code to a https url. Related valyala#244
gabrielperezs added a commit to gabrielperezs/fasthttp that referenced this issue Sep 19, 2018
gabrielperezs added a commit to gabrielperezs/fasthttp that referenced this issue Sep 19, 2018
The test code create two servers. One with TLS and the other
without. The a client will send a request to the http and will
receive an 301 code to a https url. Related valyala#244
erikdubbelboer pushed a commit to gabrielperezs/fasthttp that referenced this issue Oct 8, 2018
kirillDanshin pushed a commit that referenced this issue Oct 14, 2018
@erikdubbelboer
Copy link
Collaborator

This is fixed now that 996610f has been merged.

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

No branches or pull requests

2 participants