Skip to content

Request hangs with deflate-encoded data #9

Description

@georgepittock

Example:

package main

import (
	"fmt"
	fhttp "github.com/useflyent/fhttp"
	"io/ioutil"
	"log"
	"net/http"
	"time"
)

func main() {
		t := time.Second * 30
		// net/http
		client := &http.Client{Timeout: t}
		req, err := http.NewRequest("GET", "https://httpbin.org/deflate", nil)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println("Initiating request: net/http")
		resp, err := client.Do(req)
		if err != nil {
			log.Fatal(err)
		}
		defer resp.Body.Close()
		bodyText, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("%s\n", bodyText)

		// fhttp
		fclient := &fhttp.Client{Timeout: t}
		freq, err := fhttp.NewRequest("GET", "https://httpbin.org/deflate", nil)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println("Initiating request: fhttp")
		fresp, err := fclient.Do(freq)
		if err != nil {
			log.Fatal(err)
		}
		defer fresp.Body.Close()
		text, err := ioutil.ReadAll(fresp.Body)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("%s\n", text)
	}

This outputs:

Initiating request: net/http
gJ�J�L�����w^��F��M1&��o���w��=����F��X%h�hQR^��}��MD�
Initiating request: fhttp
reset err CANCEL StreamID: 1
2021/08/06 18:37:35 Get "https://httpbin.org/deflate": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

Go version:
go version go1.16.3 windows/amd64

It appears to work with net/http but not with fhttp

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions