Closed N0el4kLs closed 2 months ago
RawURL 就是发请求是直接传入的url字符串, 比如 Get(url) 中的url。
可以用Client中间件获取完整URL
package main
import (
"fmt"
"github.com/imroc/req/v3"
)
func main() {
c := req.C().
WrapRoundTripFunc(func(rt req.RoundTripper) req.RoundTripFunc {
return func(req *req.Request) (resp *req.Response, err error) {
fmt.Println(req.URL.String())
return rt.RoundTrip(req)
}
})
c.R().SetQueryParam("test", "1").MustGet("http://httpbin.org/get")
}
谢谢大佬解答疑惑🙏。ps:主要是遇到的好多RawURL字段都表示完整请求地址,习惯了
大佬你好,
Request.RawURL 的值是直接来自于 Send() 方法传入的地址。如果使用 SetQueryString() 等方法设置查询字符,并不会影响到 RawURL 字段。
这里想请教大佬两个问题: