CORSドメイン間説明

8198 ワード

        ajax        XMLHttpRequest  
  ajax        
1.  flash    
2.          
3.JSONP     getjavascript                       JavaScript  
4.CORS           HTML5,                 :CORS

    CORS  Cross-Origin Resource SharingHTML5             
      CORS          
    Origin    ,            。              ,          ,    
    Access-Control-Allow-Origin      ,        ,       
            
                    GET /res/abc.data
                    Host:sina.com
                    User-Agent:Mozila/5.0 xxx
                    Origin:http://my.com
           my.com   ---------------------------------------------> sina.com
                                        Http/1.1 200 ok
                    Access-AControl-Allow-Origin:http://my.com
                    Content-Type:application/xml

                    [xml data...]

   GETHEADPOST(POST Content-Type    application/x-www-form-urlencoded
   multipart/form-data text/plain,            (   X-Custom:12345)90%   
     PUTDELETE       application/json POST  ,   ajax         OPTIONS  (  preflighted  )
      URL            
                 OPTIONS /path/to/resource HTTP/1.1
                 Host: bar.com
                 Origin: http://my.com
                 Access-Control-Request-Method: POST
                Method
                 HTTP/1.1 200 OK
                 Access-Control-Allow-Origin: http://my.com
                 Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS
                 Access-Control-Max-Age: 86400