zoukankan      html  css  js  c++  java
  • fetch进行post请求为什么会首先发一个options 请求?

    不仅仅是fetch,只要你满足以下几种情况,都会去发起一个 Preflighted requests,也就是options请求,参见上面链接。

    It uses methods other than GET, HEAD or POST. Also, if POST is used to send request data with a Content-Type other than application/x-www-form-urlencoded, multipart/form-data, ortext/plain, e.g. if the POST request sends an XML payload to the server using application/xmlor text/xml, then the request is preflighted.
    It sets custom headers in the request (e.g. the request uses a header such as X-PINGOTHER)

    你看看你是不是触发这几个条件中的其中一种了吧,浏览器在发起跨域请求的时候会带着一个`Origin` header,那么其实就是个custom headers,那么也就会先触发一个Preflighted requests,
    Fetch Standard 也有提到。
    ---------------------
    作者:弹琴弹琴
    来源:CSDN
    原文:https://blog.csdn.net/bbsyi/article/details/79023655
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    hduoj1285确定比赛名次
    HDU 1041 Computer Transformation 数学DP题解
    使用Git【转】
    Git-标签管理【转】
    Git-分支管理【转】
    Git-远程仓库【转】
    Git-时光穿梭【转】
    创建版本库【转】
    安装Git【转】
    Git简介【转】
  • 原文地址:https://www.cnblogs.com/gao88/p/11260777.html
Copyright © 2011-2022 走看看