跨域请求中的option请求

最近在工作中,遇到了跨域请求的问题,其中有的请求用到了option欲请求,所以今天总结一下。

跨域请求出现options请求的原因:

Unlike “simple requests” (discussed above), "preflighted" requests first send an HTTP request by the OPTIONS method to the resource on the other domain, in order to determine whether the actual request is safe to send

翻译过来就是:复杂跨域请求,首先会发送一个options请求来决定真正的请求是否足够安全。

那么如果区分简单请求以及复杂请求就比较关键了,下面是几个关键的点:

method

  • GET
  • POST
  • HEAD

headers

  • Accept
  • Accept-Language
  • Content-Language
  • Content-Type

其中 content-type 值只包括

  • application/x-www-form-urlencoded
  • multipart/form-data
  • text/plain
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,424评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,811评论 0 23
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,906评论 0 0
  • 台风天和不上班的工作日。
    烟涩寒阅读 217评论 0 0
  • 小外孙因积食而发热,从贴药到挂水到口服药,从社区医院到香港路儿童医院,前前后后折腾六天之久。虽天气炎热我依然坚持早...
    漫天雪_15ac阅读 419评论 0 9