[HTTP] Origins, CROS, Preflight

Origins made up of three parts the data scheme, the hostname and the prot.

It is important to know that it is user broswere enforces the same origin policy, it is the client browser not allow you send the different origin request not the server.

CROS:

Client side send the request, server side will check wheterh "Access-Control-Allow-Origin" is the same as "Referer".

One problem for this is request is already send to server, include all the data. What we want is from client side, we just sent the min-info to check the CROS, instead of sending business data.

So there is Preflight request comes in to play.

Preflight request:

It sends OPTIONS methoda and with "Referer", so server only needs to check "Referer" and return "ACAO".

To check whether a request is a Preflight request, you need to see whether it has "OPTIONS" method in the request head.

But notice, if a request is come from a form , then it cannot be preflight. See MORE

Preflighted requests

Unlike simple requests (discussed above), "preflighted" requests first send an HTTP request by theOPTIONS method to the resource on the other domain, in order to determine whether the actual request is safe to send.  Cross-site requests are preflighted like this since they may have implications to user data.  In particular, a request is preflighted if:

  • 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-urlencodedmultipart/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)
时间: 2024-12-19 16:32:51

[HTTP] Origins, CROS, Preflight的相关文章

皮内的预检模块i-Cut Layout Essential & Preflight v14.0

i-Cut Layout Essential & Preflight v14.0 for MacOSX 2CD 皮内的预检模块  皮内的预检 对于Mac windowstrial试验  一个简单的PDF预检,预检带来PstI酶切和大幅面打印编辑解决方案.  皮内的准备是一个真正的工作流的起点.问题自动报告,在打印前.没有必要去Adobe?插画?和浪费时间试图找出为什么文件将不能正确打印.皮内的预检会告诉自动.  真正的形状与皮内的布局模块嵌套  皮内的布局至关重要  皮内的布局基本符合所有基本功

HDU 5652 India and China Origins 并查集

India and China Origins Problem Description A long time ago there are no himalayas between India and China, the both cultures are frequently exchanged and are kept in sync at that time, but eventually himalayas rise up. With that at first the communa

并查集(逆序处理):HDU 5652 India and China Origins

India and China Origins Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 676    Accepted Submission(s): 227 Problem Description A long time ago there are no himalayas between India and China, the

转 Js 跨域CORS报错 Response for preflight has invalid HTTP status code 405

转自:http://www.cnblogs.com/SilenceTom/p/6697484.html 调用接口遇到Response for preflight has invalid HTTP status code 405这样的错误,是使用PUT方式提交请求接口.Content-Type设置为application/json,JS代码如下: $.ajax({ type: "PUT", url: "http://172.16.200.84:8977/Messages?ses

hdu 5652 India and China Origins 并查集+二分

India and China Origins Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description A long time ago there are no himalayas between India and China, the both cultures are frequently exchanged and are kept in

【HDOJ 5652】 India and China Origins(并查集)

[HDOJ 5652] India and China Origins(并查集) India and China Origins Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 805    Accepted Submission(s): 272 Problem Description A long time ago there are

preflight

Preflighted requests 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.  Cross-

Js 跨域CORS报错 Response for preflight has invalid HTTP status code 405

调用接口遇到Response for preflight has invalid HTTP status code 405这样的错误,是使用PUT方式提交请求接口.Content-Type设置为application/json,JS代码如下: $.ajax({ type: "PUT", url: "http://172.16.200.84:8977/Messages?sessionId=ee876bfbtest", data:data, beforeSend: fu

[oldboy-django][2深入django]浏览器同源策略 + JSONP + cros

浏览器的同源策略: - 同源: 同方法,同域名,同端口 http://www.baidu.com:8000 http: 方法 www.baidu.com: 域名 8000: 端口 - 定义 网上解析非常好的一篇 http://www.ruanyifeng.com/blog/2016/04/same-origin-policy.html - 限制 ajax只能发给同源的网址: 限制原理: 浏览器request--->跨域服务器 浏览器阻止接收<----跨域服务器响应, 服务器已经做出响应了,而且