25.02.2013 Views

Peter Lubbers - Pro HTML 5 Programming

Pro HTML 5 Programming

Pro HTML 5 Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 5-4. Difference between client-side and server-side aggregation<br />

CHAPTER 5 ■ USING THE COMMUNICATION APIS<br />

The CORS specification dictates that, for sensitive actions—for example, a request with credentials,<br />

or a request other than GET or POST—an OPTIONS preflight request must be sent to the server by the<br />

browser to see whether the action is supported and allowed. This means that successful communication<br />

may require a CORS-capable server. Listings 5-5 and 5-6 show the HTTP headers involved in a crossorigin<br />

exchange between a page hosted on www.example.com and a service hosted on www.example.net.<br />

Listing 5-5. Example request headers<br />

POST /main HTTP/1.1<br />

Host: www.example.net<br />

User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090910 Ubuntu/9.04<br />

(jaunty) Shiretoko/3.5.3<br />

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br />

Accept-Language: en-us,en;q=0.5<br />

Accept-Encoding: gzip,deflate<br />

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br />

Keep-Alive: 300<br />

Connection: keep-alive<br />

Referer: http://www.example.com/<br />

127

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!