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)

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

  1. CROS跨域请求处理

    1.什么是跨域? 跨域是指从一个域名的网页去请求另一个域名的资源.比如从www.baidu.com 页面去请求 www.google.com 的资源.跨域的严格一点的定义是:只要 协议,域名,端口有任 ...

  2. AJAX from S3 CORS fails on preflight OPTIONS with 403

    解决办法: 将 <!-- Sample policy --> <CORSConfiguration> <CORSRule> <AllowedOrigin> ...

  3. Cross-origin resource sharing JSON with Padding 同源策略 JSONP 为什么form表单提交没有跨域问题,但ajax提交有跨域问题? XMLHttpRequest and the Fetch API follow the same-origin policy 预检请求(preflight request)

    https://zh.wikipedia.org/wiki/跨来源资源共享 跨来源资源共享(CORS)是一份浏览器技术的规范,提供了 Web 服务从不同域传来沙盒脚本的方法,以避开浏览器的同源策略[1 ...

  4. SpringMVC解决跨域问题及CROS

    CORS 首先因为最近在做一个前后端分离的项目,分开就意味着可能不在一个域中,所以不可避免的遇到CORS的问题.试过几个方法: Spring MVC 4.2.5以后新增的支持跨域的注解@CrossOr ...

  5. 使用Spring CROS解决项目中的跨域问题

    CROS(Cross-Origin Resource Sharing) 用于解决浏览器中跨域请求的问题.简单的Get请求可以使用JSONP来解决,而对于其它复杂的请求则需要后端应用的支持CROS.Sp ...

  6. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' heade

    XMLHttpRequest cannot load http://10.164.153.37:8050/WebService/WebService.asmx/wsGetStreetData. Res ...

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

    India and China Origins Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/ ...

  8. 让 QtWebkit 支持跨域CROS - nowboy的CSDN博客 - 博客频道 - CSDN.NET

    让 QtWebkit 支持跨域CROS - nowboy的CSDN博客 - 博客频道 - CSDN.NET 让 QtWebkit 支持跨域CROS 2013-05-23 22:05 450人阅读 评论 ...

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

    问题 公司项目H5调用接口遇到Response for preflight has invalid HTTP status code 405这样的错误,是使用PUT方式提交请求接口.Content-T ...

随机推荐

  1. http://blog.csdn.net/shirdrn/article/details/6270506

    http://blog.csdn.net/shirdrn/article/details/6270506

  2. [Gauss]POJ1830 开关问题

    中文题 题意不多说 这题乍一看 就是求个自由未知量个数 相当简单 其实呢 其中要注意的细节还是很多的: 1.光求了自由未知量个数 还不够 ∵求的是可行方案的总数  因此 答案是 2^(自由未知量个数) ...

  3. JAVA 字符串编码总结

    java 为了解决跨平台,字符串编码的有点特殊 String newStr = new String(oldStr.getBytes(), "UTF-8");java中的Strin ...

  4. 重温XML

    关于什么是XML,以及XML有什么作用,网络上很多,我就在这里不班门弄斧,写博客,是我的一个习惯,究其内容无非个人情感,心得体会,转载,技术相关的,或者一时心血来潮的个人之谈,但是我是一个小心翼翼的人 ...

  5. matlab numpy equivalents

    THIS IS AN EVOLVING WIKI DOCUMENT. If you find an error, or can fill in an empty box, please fix it! ...

  6. linux移植简介[MS2]

    一:修改Makefile 1添加编译选项,2添加时钟 二:图形化配置(make menuconfig) 此时生成zlmage,  可以跑起来 三:对NandFlash配置,yaffs2 文件系统配置, ...

  7. ERP 能够做什么

    1. ERP 能解决既有物料短缺又有库存积压的库存管理难题 企业在管理库存问题上,经常处于两难之中. 要多存物料,肯定会积压资金:少存物料,又怕物料短缺,影响生产. 这样,物料的短缺和库存积压总是同时 ...

  8. URAL1017. Staircases

    链接 简单递推 #include <iostream> #include<cstdio> #include<cstring> #include<algorit ...

  9. hadoop 序列化源码浅析

    1.Writable接口         Hadoop 并没有使用 JAVA 的序列化,而是引入了自己实的序列化系统, package org.apache.hadoop.io 这个包中定义了大量的可 ...

  10. [HDU 1806] Frequent values

    Frequent values Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...