-
-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
bugSomething isn't workingSomething isn't working
Description
TLS client version
v1.9.1
System information
Fedora 42
Issue description
I have noticed a regression in the behavior of the DisableCompression transport option. When http1 is used and accept-encoding header contains gzip, the body will be uncompressed even if DisableCompression = true.
Steps to reproduce / Code Sample
http request is used to force http1 protocol.
package main
import (
"fmt"
"log"
http "github.com/bogdanfinn/fhttp"
tls_client "github.com/bogdanfinn/tls-client"
)
func main() {
transportOptions := &tls_client.TransportOptions{
DisableCompression: true,
}
options := []tls_client.HttpClientOption{
tls_client.WithTransportOptions(transportOptions),
}
client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...)
if err != nil {
log.Println(err)
return
}
// Request 1, with gzip in the Accept-Encoding header
req1, err := http.NewRequest(http.MethodGet, "http://www.google.com", nil)
if err != nil {
log.Println(err)
return
}
req1.Header = http.Header{
"Accept-Encoding": {"gzip, deflate, br"},
}
resp1, err := client.Do(req1)
if err != nil {
log.Println(err)
return
}
defer resp1.Body.Close()
log.Println(fmt.Sprintf("uncompressed: %t, %d", resp1.Uncompressed, resp1.ProtoMajor))
// Request 2, without gzip in the Accept-Encoding header
req2, err := http.NewRequest(http.MethodGet, "http://www.google.com", nil)
if err != nil {
log.Println(err)
return
}
req2.Header = http.Header{
"Accept-Encoding": {"deflate, br"},
}
resp2, err := client.Do(req2)
if err != nil {
log.Println(err)
return
}
defer resp2.Body.Close()
log.Println(fmt.Sprintf("uncompressed: %t, %d", resp2.Uncompressed, resp2.ProtoMajor))
}
Will output:
2025/04/23 17:39:16 uncompressed: true, 1
2025/04/23 17:39:16 uncompressed: false, 1
It looks like the cause of it is this line https://github.com/bogdanfinn/fhttp/blob/master/transport.go#L2571 , introduced in bogdanfinn/fhttp#7
I confirmed that the bug is not present in v1.7.8:
2025/04/23 17:44:49 uncompressed: false, 1
2025/04/23 17:44:49 uncompressed: false, 1
Was the line in question added by mistake and could it be removed?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working