gpt4 book ai didi

google-chrome - 如何在 Google Chrome 中正确响应 HTTP CONNECT

转载 作者:行者123 更新时间:2023-12-04 06:11:49 32 4
gpt4 key购买 nike

我正在构建一个代理服务器,在收到 HTTP CONNECT 请求后,我建立到目标服务器的连接,如果成功返回

HTTP/1.1 200 Connection established
<<empty line>>

在 Firefox 中,这会导致隧道的打开和数据的交换、加载并最终在浏览器中传递/呈现

在谷歌浏览器中,我立即看到:
ERR_TUNNEL_CONNECTION_FAILED

由于服务器似乎对 Firefox 运行良好,但不适用于 Chrome,我只能假设 Chrome 期望得到不同的响应。有谁知道我在这里做错了什么?

编辑:

我找到了 this此处描述相同症状的 Chrome 问题 - 用户获得 ERR_TUNNEL_CONNECTION_FAILED。我启用了 --log-net-log 命令行参数,在日志中可以看到在收到我的 200 Connection created proxy 响应后直接发生了 ERR_TUNNEL_CONNECTION_FAILED 错误。

在请求和响应之间,我看到一个 -109 错误,它对应于 ADDRESS_UNREACHABLE。

我在下面包含了我认为网络日志的相关部分的摘录:
{"params":{"headers":["Host: mail.google.com","Proxy-Connection: keep-alive","User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"],"line":"CONNECT mail.google.com:443 HTTP/1.1\r\n"},"phase":0,"source":{"id":822,"type":5},"time":"331488980","type":125},
{"params":{"headers":["Host: mail.google.com","Proxy-Connection: keep-alive","User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"],"line":"CONNECT mail.google.com:443 HTTP/1.1\r\n"},"phase":0,"source":{"id":822,"type":5},"time":"331488980","type":129},
{"params":{"byte_count":227},"phase":0,"source":{"id":822,"type":5},"time":"331488980","type":61},
{"phase":2,"source":{"id":822,"type":5},"time":"331488981","type":124},
{"phase":1,"source":{"id":822,"type":5},"time":"331488981","type":126},
{"phase":1,"source":{"id":822,"type":5},"time":"331488981","type":207},
{"params":{"address_family":0,"allow_cached_response":true,"host":"mail.google.com:0","is_speculative":false,"source_dependency":{"id":0,"type":0}},"phase":1,"source":{"id":823,"type":8},"time":"331489008","type":4},
{"params":{"source_dependency":{"id":823,"type":8}},"phase":1,"source":{"id":824,"type":21},"time":"331489008","type":299},
{"params":{"source_dependency":{"id":824,"type":21}},"phase":1,"source":{"id":825,"type":14},"time":"331489008","type":34},
{"params":{"address":"[2001:4860:4860::8888]:53"},"phase":1,"source":{"id":825,"type":14},"time":"331489008","type":70},
{"params":{"net_error":-109},"phase":2,"source":{"id":825,"type":14},"time":"331489008","type":70},
{"phase":2,"source":{"id":825,"type":14},"time":"331489008","type":34},
{"phase":2,"source":{"id":824,"type":21},"time":"331489008","type":299},
{"phase":0,"source":{"id":823,"type":8},"time":"331489008","type":6},
{"phase":2,"source":{"id":823,"type":8},"time":"331489008","type":4},
{"params":{"byte_count":74},"phase":0,"source":{"id":822,"type":5},"time":"331489052","type":63},
{"phase":2,"source":{"id":822,"type":5},"time":"331489052","type":207},
{"params":{"headers":["HTTP/1.1 200 Connection established"]},"phase":0,"source":{"id":822,"type":5},"time":"331489052","type":127},
{"params":{"net_error":-111},"phase":2,"source":{"id":822,"type":5},"time":"331489052","type":126},

如果您需要查看更多日志,我已经发布了整个日志 here

最佳答案

有点晚了,但我自己就遇到了这个问题。在我的情况下发生的事情是我在 CONNECT 响应中发送了一个额外的字节。
通过在 Chrome 中启用 NetLog(在一切捕获模式下)发现这一点:

--> bytes =
48 54 54 50 2F 31 2E 31 20 32 30 30 20 43 6F 6E HTTP/1.1 200 Con
6E 65 63 74 69 6F 6E 20 65 73 74 61 62 6C 69 73 nection establis
68 65 64 0D 0A 0D 0A 00 hed....

查看尾随的 00。Chrome(和 curl)似乎是 more strict与 Firefox 或 Safari 相比,您发送的整个缓冲区需要是格式良好的 HTTP 响应。

我建议你 capture a full NetLog dump并查看 Chrome 接收的字节数。

关于google-chrome - 如何在 Google Chrome 中正确响应 HTTP CONNECT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24656350/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com