req icon indicating copy to clipboard operation
req copied to clipboard

Simple Go HTTP client with Black Magic

Results 105 req issues
Sort by recently updated
recently updated
newest added

在使用 HTTP/2 时,经常触发 `http2: Transport received Server's graceful shutdown GOAWAY` 错误,请问我该如何处理掉这个错误?

```go var repsClient = req.C(). SetBaseURL("https://sc.scm121.com/api").SetCommonContentType("application/json; charset=utf-8"). SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36"). SetTimeout(1 * time.Minute).EnableDumpAllToFile("./runtime/dumpReq.txt") func (c Content) RequestGet(url string, urlParams map[string]string) (JSON,...

There is a small mistake in the [Get Response body](https://req.cool/docs/tutorial/handle-response/#get-response-body-as-string-or-byte) in the documentation. More specific the example for the `ToBytes()` is: ```go body, err := resp.ToString() if err != nil...

``` go func TestHttps(t *testing.T) { c := req.C().EnableDumpAll().SetBaseURL("https://httpbin.org") r := c.R() r.SetHeadersNonCanonical(map[string]string{ "USID": "123", // 用户 ID }) r.SetHeaderNonCanonical("CTERMINAL", "ui") res, _ := r.Post("/post") t.Log(res.String()) } /* :authority: httpbin.org...

http1.1、http2都支持SetTLSFingerprint,那么http3有计划支持吗?目前看是不支持的

`goroutine 5677 [running]: github.com/imroc/req/v3.parseRequestHeader(0xc000626dc0, 0xc000a44000) /root/go/pkg/mod/github.com/imroc/req/[email protected]/middleware.go:537 +0x391 github.com/imroc/req/v3.(*Request).do(0xc000a44000) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:660 +0xac7 github.com/imroc/req/v3.(*Request).Do(0xc000a44000, {0x0, 0x0, 0xc000e067b0?}) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:636 +0x38f github.com/imroc/req/v3.(*Request).Send(0xc000a44000, {0xec2aad, 0x3}, {0xc000042540, 0x3c}) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:726 +0xfb github.com/imroc/req/v3.(*Request).Get(...) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:745 main.(*config).request.func4({0xc000042540, 0x3c}, 0x3, 0xc000590200) /opt/go-project/net_check/test2.go:529...

![Image](https://github.com/user-attachments/assets/57d6ca20-98cb-4bd3-a3cf-093bad8830ff) 此处的代码导致切换代理时,使用缓存的连接去处理,但是缓存的key是简单的 host:port 而不是connectMethod,这样设置了新代理以后还是使用的以前的连接

```golang webHttpClient := req.NewClient() webHttpClient. ImpersonateChrome(). SetCookieJar(nil). SetTimeout(10*time.Second). DisableKeepAlives(). SetCommonRetryCount(3). // 最大重试3次 SetCommonRetryBackoffInterval(1*time.Second, 4*time.Second). SetCommonRetryCondition(func(resp *req.Response, err error) bool { if resp.GetStatusCode() == 202 || resp.IsErrorState() && resp.GetStatusCode() != 404...

#### repro steps 1. Replace [PATH] with a 100MB+ file. 2. observe memory usage ```go package main import ( "fmt" "github.com/imroc/req/v3" ) func main() { client := req.C().EnableDumpAllWithoutBody() res, err...

鉴于 Do 函数已经存在,所以 建议如下方式实现 type Doer interface { Do(*http.Request) ( *http.Respone,error) } req.C().Doer() 返回一个 基于client的 Doer的实现 req.C().R().Doer() 返回一个基于Request 的 Doer实现