Closed karliehgf closed 1 month ago
问题原因:hertz client 发请求默认会带一个 user-agent header;可能 baidu 的接口认为这个 user-agent 是一个爬虫或者什么的,就返回了一个 js 重定向页面(具体原因目前不清楚)。 解决方法:配置下不带默认user-agent就可以了
c, _ := NewClient(WithDialer(standard.NewDialer()), WithNoDefaultUserAgentHeader(true))
Describe the bug i use client.NewClient() to fetch a https request, if the target server will enforce HTTP to HTTPS redirection, i will fetch the wrong http response. example code:
result:![image](https://github.com/cloudwego/hertz/assets/8002468/10b87f87-61a7-4b1e-a197-80f58bd20ec5)
however, it worked well if i change the request uri to "http://www.baidu.com". And the result is:![image](https://github.com/cloudwego/hertz/assets/8002468/700b95db-306f-43ae-8ba8-db86dec5265a)
Hertz version:
hertz v0.9.1
Environment:
go version: go1.21.8
Additional context
Add any other context about the problem here.