Cross-origin resource sharing是一种允许网页向另一个域(从Wikipedia)发出XMLHttpRequests的机制.
在过go 的几天里,我一直在摆弄CORS,我想我对每件事的运作方式都有很好的理解.
所以我的问题不是CORS/飞行前是如何工作的,而是大约the reason behind coming up with preflights as a new request type个.我看不出为什么服务器A需要向服务器B发送预飞行(PR)只是为了确定实际请求(RR)是否会被接受——B当然有可能在没有任何预飞行(PR)的情况下接受/拒绝RR.
在搜索了相当多之后,我找到了www.w3.org(7.1.5)的this piece条信息:
To protect resources against cross-origin requests that could not originate from certain user agents before this specification existed a preflight request is made to ensure that the resource is aware of this specification.
我发现这是有史以来最难理解的句子.我的解释(最好称之为"最佳猜测")是,它是关于保护服务器B不受服务器C不知道规范的请求的影响.
有人能解释一个场景/展示一个PR+RR比RR单独解决的问题吗?