[英]iOS native WebSockets and http 301 redirects
在尝试使用 iOS 原生 WebSockets 时,我注意到在初始套接字构建阶段有一个奇怪的行为。
如果我使用 URLSession.webSocketTask(_:) 使用带有 URL 的 URLRequest 创建一个套接字,它没有斜线符号(例如https://example.com/socket ),然后我尝试恢复()我的任务've noticed that the very first time I receive an http 301 (moved permanently) response from the server to the same exact connection URL but with a "/" appended as a suffix, and then an http 101 (switching protocols).
有趣的是,在第一次连接之后,如果我销毁套接字任务 object 并使用相同的 URL 没有斜杠后缀创建一个新的任务,这次我只会得到一个 Z80791B3AE7002FAA9Z10876 响应。
It's as if there is some sort of internal connection table lookup inside the URLSession object which remembers the http 301 for a specific endpoint and the next time that URL is used it automatically apply the corrected URL (ie after the moved permanently url update).
有没有人遇到过同样的行为?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.