gpt-3.5-turbo-0301· openai
Suzhen/CodeChat
使用golang的fasthttp库,访问出现了first record does not look like a TLS handshake
- User
使用golang的fasthttp库,访问出现了first record does not look like a TLS handshake
- Assistant
错误,该错误通常是由于访问的服务器不支持TLS连接或提供的证书不受信任导致的。您可以尝试在请求中添加跳过TLS验证的选项,如下所示:
url := "https://example.com" req := fasthttp.AcquireRequest() defer fasthttp.ReleaseRequest(req) req.SetRequestURI(url) req.Header.SetMethod("GET") req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0") req.Header.Set("Accept-Encoding", "gzip, deflate, br") req.Header.Set("Connection", "keep-alive") req.Header.Set("Pragma", "no-cache") req.Header.Set("Cache-Control", "no-cache") // 添加跳过TLS验证选项 tlsConfig := &tls.Config{ InsecureSkipVerify: true, } client := &fasthttp.Client{ TLSConfig: tlsConfig, } resp := fasthttp.AcquireResponse() defer fasthttp.ReleaseResponse(resp) err := client.Do(req, resp) if err != nil { log.Printf("请求失败:%v", err) } else { log.Printf("请求成功,响应:%s", resp.Body()) }注意,跳过TLS验证会降低连接的安全性,建议只在调试或测试环境中使用。在生产环境中应该使用受信任的证书和正常的TLS验证方法。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.