09.11.2016 Views

Foundations of Python Network Programming 978-1-4302-3004-5

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

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

CHAPTER 9 ■ HTTP<br />

• URLs and their structure.<br />

• The GET method and fetching documents.<br />

• How the Host: header makes up for the fact that the hostname from the URL is not<br />

included in the path that follows the word GET.<br />

• The success and error codes returned in HTTP responses and how they induce<br />

browser actions like redirection.<br />

• How persistent connections can increase the speed at which HTTP resources can<br />

be fetched.<br />

• The POST method for performing actions and submitting forms.<br />

• How redirection should always follow the successful POST <strong>of</strong> a web form.<br />

• That POST is <strong>of</strong>ten used for web service requests from programs and can directly<br />

return useful information.<br />

• Other HTTP methods exist and can be used to design web-centric applications<br />

using a methodology called REST.<br />

• Browsers identify themselves through a user agent string, and some servers are<br />

sensitive to this value.<br />

• Requests <strong>of</strong>ten specify what content types a client can display, and well-written<br />

servers will try to choose content representations that fit these constraints.<br />

• Clients can request—and servers can use—compression that results in a page<br />

arriving more quickly over the network.<br />

• Several headers and a set <strong>of</strong> rules govern which HTTP-delivered documents can<br />

and cannot be cached.<br />

• The HEAD command only returns the headers.<br />

• The HTTPS protocol adds TLS/SSL protection to HTTP.<br />

• An old and awkward form <strong>of</strong> authentication is supported by HTTP itself.<br />

• Most sites today supply their own login form and then use cookies to identify<br />

users as they move across the site.<br />

• If a cookie is captured, it can allow an attacker to view a web site as though the<br />

attacker were the user whose cookie was stolen.<br />

• Even more difficult classes <strong>of</strong> attack exist on the modern dynamic web, collectively<br />

called cross-site-scripting attacks.<br />

Armed with the knowledge and examples in this chapter, you should be able to use the urllib2<br />

module from the Standard Library to fetch resources from the Web and even implement primitive<br />

browser behaviors like retaining cookies.<br />

162

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

Saved successfully!

Ooh no, something went wrong!