diff --git a/dip2 b/dip2 index 1802b20..5009412 100644 --- a/dip2 +++ b/dip2 @@ -4567,820 +4567,17 @@ def main(argv):
getopt
-You've learned about HTML processing and XML processing, and along the way you saw how to download a web page and how to parse XML from a URL, but let's dive into the more general topic of HTTP web services. -
Simply stated, HTTP web services are programmatic ways of sending and receiving data from remote servers using the operations -of HTTP directly. If you want to get data from the server, use a straight HTTP GET; if you want to send new data to the server, -use HTTP POST. (Some more advanced HTTP web service APIs also define ways of modifying existing data and deleting data, using -HTTP PUT and HTTP DELETE.) In other words, the “verbs” built into the HTTP protocol (GET, POST, PUT, and DELETE) map directly to application-level operations for receiving, sending, -modifying, and deleting data. -
The main advantage of this approach is simplicity, and its simplicity has proven popular with a lot of different sites. Data --- usually XML data -- can be built and stored statically, or generated dynamically by a server-side script, and all major -languages include an HTTP library for downloading it. Debugging is also easier, because you can load up the web service in -any web browser and see the raw data. Modern browsers will even nicely format and pretty-print XML data for you, to allow -you to quickly navigate through it. -
Examples of pure XML-over-HTTP web services: -
In later chapters, you'll explore APIs which use HTTP as a transport for sending and receiving data, but don't map application -semantics to the underlying HTTP semantics. (They tunnel everything over HTTP POST.) But this chapter will concentrate on -using HTTP GET to get data from a remote server, and you'll explore several HTTP features you can use to get the maximum benefit -out of pure HTTP web services. -
Here is a more advanced version of the openanything module that you saw in the previous chapter:
-
openanything.pyIf you have not already done so, you can download this and other examples used in this book. -
-import urllib2, urlparse, gzip
-from StringIO import StringIO
-USER_AGENT = 'OpenAnything/1.0 +http://diveintopython3.org/http_web_services/'
+[HTTP web services stuff was here]
-class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
- def http_error_301(self, req, fp, code, msg, headers):
- result = urllib2.HTTPRedirectHandler.http_error_301(
- self, req, fp, code, msg, headers)
- result.status = code
- return result
- def http_error_302(self, req, fp, code, msg, headers):
- result = urllib2.HTTPRedirectHandler.http_error_302(
- self, req, fp, code, msg, headers)
- result.status = code
- return result
-class DefaultErrorHandler(urllib2.HTTPDefaultErrorHandler):
- def http_error_default(self, req, fp, code, msg, headers):
- result = urllib2.HTTPError(
- req.get_full_url(), code, msg, headers, fp)
- result.status = code
- return result
-def openAnything(source, etag=None, lastmodified=None, agent=USER_AGENT):
- '''URL, filename, or string --> stream
- This function lets you define parsers that take any input source
- (URL, pathname to local or network file, or actual data as a string)
- and deal with it in a uniform manner. Returned object is guaranteed
- to have all the basic stdio read methods (read, readline, readlines).
- Just .close() the object when you're done with it.
-
- If the etag argument is supplied, it will be used as the value of an
- If-None-Match request header.
-
- If the lastmodified argument is supplied, it must be a formatted
- date/time string in GMT (as returned in the Last-Modified header of
- a previous request). The formatted date/time will be used
- as the value of an If-Modified-Since request header.
-
- If the agent argument is supplied, it will be used as the value of a
- User-Agent request header.
- '''
-
- if hasattr(source, 'read'):
- return source
-
- if source == '-':
- return sys.stdin
-
- if urlparse.urlparse(source)[0] == 'http':
- # open URL with urllib2
- request = urllib2.Request(source)
- request.add_header('User-Agent', agent)
- if etag:
- request.add_header('If-None-Match', etag)
- if lastmodified:
- request.add_header('If-Modified-Since', lastmodified)
- request.add_header('Accept-encoding', 'gzip')
- opener = urllib2.build_opener(SmartRedirectHandler(), DefaultErrorHandler())
- return opener.open(request)
-
- # try to open with native open function (if source is a filename)
- try:
- return open(source)
- except (IOError, OSError):
- pass
-
- # treat source as string
- return StringIO(str(source))
-
-def fetch(source, etag=None, last_modified=None, agent=USER_AGENT):
- '''Fetch data and metadata from a URL, file, stream, or string'''
- result = {}
- f = openAnything(source, etag, last_modified, agent)
- result['data'] = f.read()
- if hasattr(f, 'headers'):
- # save ETag, if the server sent one
- result['etag'] = f.headers.get('ETag')
- # save Last-Modified header, if the server sent one
- result['lastmodified'] = f.headers.get('Last-Modified')
- if f.headers.get('content-encoding', '') == 'gzip':
- # data came back gzip-compressed, decompress it
- result['data'] = gzip.GzipFile(fileobj=StringIO(result['data']])).read()
- if hasattr(f, 'url'):
- result['url'] = f.url
- result['status'] = 200
- if hasattr(f, 'status'):
- result['status'] = f.status
- f.close()
- return result
-Let's say you want to download a resource over HTTP, such as a syndicated Atom feed. But you don't just want to download - it once; you want to download it over and over again, every hour, to get the latest news from the site that's offering the - news feed. Let's do it the quick-and-dirty way first, and then see how you can do better. -
->>> import urllib
->>> data = urllib.urlopen('http://diveintomark.org/xml/atom.xml').read() ①
->>> print data
-<?xml version="1.0" encoding="iso-8859-1"?>
-<feed version="0.3"
- xmlns="http://purl.org/atom/ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xml:lang="en">
- <title mode="escaped">dive into mark</title>
- <link rel="alternate" type="text/html" href="http://diveintomark.org/"/>
- <-- rest of feed omitted for brevity -->
-
-urllib module has a handy urlopen function that takes the address of the page you want, and returns a file-like object that you can just read() from to get the full contents of the page. It just can't get much easier.
-So what's wrong with this? Well, for a quick one-off during testing or development, there's nothing wrong with it. I do -it all the time. I wanted the contents of the feed, and I got the contents of the feed. The same technique works for any -web page. But once you start thinking in terms of a web service that you want to access on a regular basis -- and remember, -you said you were planning on retrieving this syndicated feed once an hour -- then you're being inefficient, and you're being -rude. -
Let's talk about some of the basic features of HTTP. -
There are five important features of HTTP which you should support. -
User-AgentThe User-Agent is simply a way for a client to tell a server who it is when it requests a web page, a syndicated feed, or any sort of web
- service over HTTP. When the client requests a resource, it should always announce who it is, as specifically as possible.
- This allows the server-side administrator to get in touch with the client-side developer if anything is going fantastically
- wrong.
-
By default, Python sends a generic User-Agent: Python-urllib/1.15. In the next section, you'll see how to change this to something more specific.
-
Sometimes resources move around. Web sites get reorganized, pages move to new addresses. Even web services can reorganize.
- A syndicated feed at http://example.com/index.xml might be moved to http://example.com/xml/atom.xml. Or an entire domain might move, as an organization expands and reorganizes; for instance, http://www.example.com/index.xml might be redirected to http://server-farm-1.example.com/index.xml.
-
Every time you request any kind of resource from an HTTP server, the server includes a status code in its response. Status
- code 200 means “everything's normal, here's the page you asked for”. Status code 404 means “page not found”. (You've probably seen 404 errors while browsing the web.)
-
HTTP has two different ways of signifying that a resource has moved. Status code 302 is a temporary redirect; it means “oops, that got moved over here temporarily” (and then gives the temporary address in a Location: header). Status code 301 is a permanent redirect; it means “oops, that got moved permanently” (and then gives the new address in a Location: header). If you get a 302 status code and a new address, the HTTP specification says you should use the new address to get what you asked for, but
- the next time you want to access the same resource, you should retry the old address. But if you get a 301 status code and a new address, you're supposed to use the new address from then on.
-
urllib.urlopen will automatically “follow” redirects when it receives the appropriate status code from the HTTP server, but unfortunately, it doesn't tell you when
- it does so. You'll end up getting data you asked for, but you'll never know that the underlying library “helpfully” followed a redirect for you. So you'll continue pounding away at the old address, and each time you'll get redirected to
- the new address. That's two round trips instead of one: not very efficient! Later in this chapter, you'll see how to work
- around this so you can deal with permanent redirects properly and efficiently.
-
Last-Modified/If-Modified-SinceSome data changes all the time. The home page of CNN.com is constantly updating every few minutes. On the other hand, the - home page of Google.com only changes once every few weeks (when they put up a special holiday logo, or advertise a new service). - Web services are no different; usually the server knows when the data you requested last changed, and HTTP provides a way - for the server to include this last-modified date along with the data you requested. -
If you ask for the same data a second time (or third, or fourth), you can tell the server the last-modified date that you
- got last time: you send an If-Modified-Since header with your request, with the date you got back from the server last time. If the data hasn't changed since then, the
- server sends back a special HTTP status code 304, which means “this data hasn't changed since the last time you asked for it”. Why is this an improvement? Because when the server sends a 304, it doesn't re-send the data. All you get is the status code. So you don't need to download the same data over and over again if it hasn't changed;
- the server assumes you have the data cached locally.
-
All modern web browsers support last-modified date checking. If you've ever visited a page, re-visited the same page a day
- later and found that it hadn't changed, and wondered why it loaded so quickly the second time -- this could be why. Your
- web browser cached the contents of the page locally the first time, and when you visited the second time, your browser automatically
- sent the last-modified date it got from the server the first time. The server simply says 304: Not Modified, so your browser knows to load the page from its cache. Web services can be this smart too.
-
Python's URL library has no built-in support for last-modified date checking, but since you can add arbitrary headers to each request - and read arbitrary headers in each response, you can add support for it yourself. -
ETag/If-None-MatchETags are an alternate way to accomplish the same thing as the last-modified date checking: don't re-download data that hasn't
- changed. The way it works is, the server sends some sort of hash of the data (in an ETag header) along with the data you requested. Exactly how this hash is determined is entirely up to the server. The second
- time you request the same data, you include the ETag hash in an If-None-Match: header, and if the data hasn't changed, the server will send you back a 304 status code. As with the last-modified date checking, the server just sends the 304; it doesn't send you the same data a second time. By including the ETag hash in your second request, you're telling the
- server that there's no need to re-send the same data if it still matches this hash, since you still have the data from the
- last time.
-
Python's URL library has no built-in support for ETags, but you'll see how to add it later in this chapter. -
The last important HTTP feature is gzip compression. When you talk about HTTP web services, you're almost always talking
- about moving XML back and forth over the wire. XML is text, and quite verbose text at that, and text generally compresses
- well. When you request a resource over HTTP, you can ask the server that, if it has any new data to send you, to please send
- it in compressed format. You include the Accept-encoding: gzip header in your request, and if the server supports compression, it will send you back gzip-compressed data and mark it with
- a Content-encoding: gzip header.
-
Python's URL library has no built-in support for gzip compression per se, but you can add arbitrary headers to the request. And
-Python comes with a separate gzip module, which has functions you can use to decompress the data yourself.
-
Note that our little one-line script to download a syndicated feed did not support any of these HTTP features. Let's see how you can improve it. -
First, let's turn on the debugging features of Python's HTTP library and see what's being sent over the wire. This will be useful throughout the chapter, as you add more and - more features. -
->>> import httplib ->>> httplib.HTTPConnection.debuglevel = 1 ① ->>> import urllib ->>> feeddata = urllib.urlopen('http://diveintomark.org/xml/atom.xml').read() -connect: (diveintomark.org, 80) ② -send: ' -GET /xml/atom.xml HTTP/1.0 ③ -Host: diveintomark.org ④ -User-agent: Python-urllib/1.15 ⑤ -' -reply: 'HTTP/1.1 200 OK\r\n' ⑥ -header: Date: Wed, 14 Apr 2004 22:27:30 GMT -header: Server: Apache/2.0.49 (Debian GNU/Linux) -header: Content-Type: application/atom+xml -header: Last-Modified: Wed, 14 Apr 2004 22:14:38 GMT ⑦ -header: ETag: "e8284-68e0-4de30f80" ⑧ -header: Accept-Ranges: bytes -header: Content-Length: 26848 -header: Connection: close --
urllib relies on another standard Python library, httplib. Normally you don't need to import httplib directly (urllib does that automatically), but you will here so you can set the debugging flag on the HTTPConnection class that urllib uses internally to connect to the HTTP server. This is an incredibly useful technique. Some other Python libraries have similar debug flags, but there's no particular standard for naming them or turning them on; you need to read
- the documentation of each library to see if such a feature is available.
-diveintomark.org on port 80, which is the standard port for HTTP.
-urllib sends three lines to the server. The first line specifies the HTTP verb you're using, and the path of the resource (minus
- the domain name). All the requests in this chapter will use GET, but in the next chapter on SOAP, you'll see that it uses POST for everything. The basic syntax is the same, regardless of the verb.
-Host header, which specifies the domain name of the service you're accessing. This is important, because a single HTTP server
- can host multiple separate domains. My server currently hosts 12 domains; other servers can host hundreds or even thousands.
-User-Agent header. What you see here is the generic User-Agent that the urllib library adds by default. In the next section, you'll see how to customize this to be more specific.
-200, meaning “everything's normal, here's the data you requested”. The server also tells you the date it responded to your request, some information about the server itself, and the content
- type of the data it's giving you. Depending on your application, this might be useful, or not. It's certainly reassuring
- that you thought you were asking for an Atom feed, and lo and behold, you're getting an Atom feed (application/atom+xml, which is the registered content type for Atom feeds).
-"e8284-68e0-4de30f80". The hash doesn't mean anything by itself; there's nothing you can do with it, except send it back to the server the next
- time you request this same feed. Then the server can use it to tell you if the data has changed or not.
-User-AgentThe first step to improving your HTTP web services client is to identify yourself properly with a User-Agent. To do that, you need to move beyond the basic urllib and dive into urllib2.
-
urllib2->>> import httplib ->>> httplib.HTTPConnection.debuglevel = 1 ① ->>> import urllib2 ->>> request = urllib2.Request('http://diveintomark.org/xml/atom.xml') ② ->>> opener = urllib2.build_opener() ③ ->>> feeddata = opener.open(request).read() ④ -connect: (diveintomark.org, 80) -send: ' -GET /xml/atom.xml HTTP/1.0 -Host: diveintomark.org -User-agent: Python-urllib/2.1 -' -reply: 'HTTP/1.1 200 OK\r\n' -header: Date: Wed, 14 Apr 2004 23:23:12 GMT -header: Server: Apache/2.0.49 (Debian GNU/Linux) -header: Content-Type: application/atom+xml -header: Last-Modified: Wed, 14 Apr 2004 22:14:38 GMT -header: ETag: "e8284-68e0-4de30f80" -header: Accept-Ranges: bytes -header: Content-Length: 26848 -header: Connection: close --
urllib2 is a three-step process, for good reasons that will become clear shortly. The first step is to create a Request object, which takes the URL of the resource you'll eventually get around to retrieving. Note that this step doesn't actually
- retrieve anything yet.
-Request object you created. As you can see from all the debugging information that gets printed, this step actually retrieves the
- resource and stores the returned data in feeddata.
-Request->>> request ① -<urllib2.Request instance at 0x00250AA8> ->>> request.get_full_url() -http://diveintomark.org/xml/atom.xml ->>> request.add_header('User-Agent', -... 'OpenAnything/1.0 +http://diveintopython3.org/') ② ->>> feeddata = opener.open(request).read() ③ -connect: (diveintomark.org, 80) -send: ' -GET /xml/atom.xml HTTP/1.0 -Host: diveintomark.org -User-agent: OpenAnything/1.0 +http://diveintopython3.org/ ④ -' -reply: 'HTTP/1.1 200 OK\r\n' -header: Date: Wed, 14 Apr 2004 23:45:17 GMT -header: Server: Apache/2.0.49 (Debian GNU/Linux) -header: Content-Type: application/atom+xml -header: Last-Modified: Wed, 14 Apr 2004 22:14:38 GMT -header: ETag: "e8284-68e0-4de30f80" -header: Accept-Ranges: bytes -header: Content-Length: 26848 -header: Connection: close --
Request object with the URL you want to access.
-add_header method on the Request object, you can add arbitrary HTTP headers to the request. The first argument is the header, the second is the value you're
- providing for that header. Convention dictates that a User-Agent should be in this specific format: an application name, followed by a slash, followed by a version number. The rest is free-form,
- and you'll see a lot of variations in the wild, but somewhere it should include a URL of your application. The User-Agent is usually logged by the server along with other details of your request, and including a URL of your application allows
- server administrators looking through their access logs to contact you if something is wrong.
-User-Agent header.
-User-Agent, in place of the generic one that Python sends by default. If you look closely, you'll notice that you defined a User-Agent header, but you actually sent a User-agent header. See the difference? urllib2 changed the case so that only the first letter was capitalized. It doesn't really matter; HTTP specifies that header field
- names are completely case-insensitive.
-Last-Modified and ETagNow that you know how to add custom HTTP headers to your web service requests, let's look at adding support for Last-Modified and ETag headers.
-
These examples show the output with debugging turned off. If you still have it turned on from the previous section, you can
-turn it off by setting httplib.HTTPConnection.debuglevel = 0. Or you can just leave debugging on, if that helps you.
-
Last-Modified
->>> import urllib2
->>> request = urllib2.Request('http://diveintomark.org/xml/atom.xml')
->>> opener = urllib2.build_opener()
->>> firstdatastream = opener.open(request)
->>> firstdatastream.headers.dict ①
-{'date': 'Thu, 15 Apr 2004 20:42:41 GMT',
- 'server': 'Apache/2.0.49 (Debian GNU/Linux)',
- 'content-type': 'application/atom+xml',
- 'last-modified': 'Thu, 15 Apr 2004 19:45:21 GMT',
- 'etag': '"e842a-3e53-55d97640"',
- 'content-length': '15955',
- 'accept-ranges': 'bytes',
- 'connection': 'close'}
->>> request.add_header('If-Modified-Since',
-... firstdatastream.headers.get('Last-Modified')) ②
->>> seconddatastream = opener.open(request) ③
-Traceback (most recent call last):
- File "<stdin>", line 1, in ?
- File "c:\python23\lib\urllib2.py", line 326, in open
- '_open', req)
- File "c:\python23\lib\urllib2.py", line 306, in _call_chain
- result = func(*args)
- File "c:\python23\lib\urllib2.py", line 901, in http_open
- return self.do_open(httplib.HTTP, req)
- File "c:\python23\lib\urllib2.py", line 895, in do_open
- return self.parent.error('http', req, fp, code, msg, hdrs)
- File "c:\python23\lib\urllib2.py", line 352, in error
- return self._call_chain(*args)
- File "c:\python23\lib\urllib2.py", line 306, in _call_chain
- result = func(*args)
- File "c:\python23\lib\urllib2.py", line 412, in http_error_default
- raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
-urllib2.HTTPError: HTTP Error 304: Not Modified
-
-If-Modified-Since header with the last-modified date from the first request. If the data hasn't changed, the server should return a 304 status code.
-urllib2 throws a special exception, HTTPError, in response to the 304 status code. This is a little unusual, and not entirely helpful. After all, it's not an error; you specifically asked the
- server not to send you any data if it hadn't changed, and the data didn't change, so the server told you it wasn't sending
- you any data. That's not an error; that's exactly what you were hoping for.
-urllib2 also raises an HTTPError exception for conditions that you would think of as errors, such as 404 (page not found). In fact, it will raise HTTPError for any status code other than 200 (OK), 301 (permanent redirect), or 302 (temporary redirect). It would be more helpful for your purposes to capture the status code and simply return it, without
-throwing an exception. To do that, you'll need to define a custom URL handler.
-
This custom URL handler is part of openanything.py.
-
-class DefaultErrorHandler(urllib2.HTTPDefaultErrorHandler): ①
- def http_error_default(self, req, fp, code, msg, headers): ②
- result = urllib2.HTTPError(
- req.get_full_url(), code, msg, headers, fp)
- result.status = code ③
- return result
-
-urllib2 is designed around URL handlers. Each handler is just a class that can define any number of methods. When something happens
- -- like an HTTP error, or even a 304 code -- urllib2 introspects into the list of defined handlers for a method that can handle it. You used a similar introspection in Chapter 9, XML Processing to define handlers for different node types, but urllib2 is more flexible, and introspects over as many handlers as are defined for the current request.
-urllib2 searches through the defined handlers and calls the http_error_default method when it encounters a 304 status code from the server. By defining a custom error handler, you can prevent urllib2 from raising an exception. Instead, you create the HTTPError object, but return it instead of raising it.
-->>> request.headers ① -{'If-modified-since': 'Thu, 15 Apr 2004 19:45:21 GMT'} ->>> import openanything ->>> opener = urllib2.build_opener( -... openanything.DefaultErrorHandler()) ② ->>> seconddatastream = opener.open(request) ->>> seconddatastream.status ③ -304 ->>> seconddatastream.read() ④ -'' --
Request object is already set up, and you've already added the If-Modified-Since header.
-urllib2 to use it. Remember how I said that urllib2 broke up the process of accessing an HTTP resource into three steps, and for good reason? This is why building the URL opener
- is its own step, because you can build it with your own custom URL handlers that override urllib2's default behavior.
-304, meaning this data hasn't changed since the last time you asked for it.
-304 status code, it doesn't re-send the data. That's the whole point: to save bandwidth by not re-downloading data that hasn't
- changed. So if you actually want that data, you'll need to cache it locally the first time you get it.
-Handling ETag works much the same way, but instead of checking for Last-Modified and sending If-Modified-Since, you check for ETag and send If-None-Match. Let's start with a fresh IDE session.
-
ETag/If-None-Match
->>> import urllib2, openanything
->>> request = urllib2.Request('http://diveintomark.org/xml/atom.xml')
->>> opener = urllib2.build_opener(
-... openanything.DefaultErrorHandler())
->>> firstdatastream = opener.open(request)
->>> firstdatastream.headers.get('ETag') ①
-'"e842a-3e53-55d97640"'
->>> firstdata = firstdatastream.read()
->>> print firstdata ②
-<?xml version="1.0" encoding="iso-8859-1"?>
-<feed version="0.3"
- xmlns="http://purl.org/atom/ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xml:lang="en">
- <title mode="escaped">dive into mark</title>
- <link rel="alternate" type="text/html" href="http://diveintomark.org/"/>
- <-- rest of feed omitted for brevity -->
->>> request.add_header('If-None-Match',
-... firstdatastream.headers.get('ETag')) ③
->>> seconddatastream = opener.open(request)
->>> seconddatastream.status ④
-304
->>> seconddatastream.read() ⑤
-''
-
-ETag returned from the server. (What happens if the server didn't send back an ETag? Then this line would return None.)
-If-None-Match header to the ETag you got from the first call.
-304 status code. Based on the ETag you sent the second time, it knows that the data hasn't changed.
-304 is triggered by Last-Modified date checking or ETag hash matching, you'll never get the data along with the 304. That's the whole point.
-In these examples, the HTTP server has supported both Last-Modified and ETag headers, but not all servers do. As a web services client, you should be prepared to support both, but you must code defensively
- in case a server only supports one or the other, or neither.
-11.7. Handling redirects-You can support permanent and temporary redirects using a different kind of custom URL handler. - First, let's see why a redirect handler is necessary in the first place. - Example 11.10. Accessing web services without a redirect handler->>> import urllib2, httplib ->>> httplib.HTTPConnection.debuglevel = 1 ① ->>> request = urllib2.Request( -... 'http://diveintomark.org/redir/example301.xml') ② ->>> opener = urllib2.build_opener() ->>> f = opener.open(request) -connect: (diveintomark.org, 80) -send: ' -GET /redir/example301.xml HTTP/1.0 -Host: diveintomark.org -User-agent: Python-urllib/2.1 -' -reply: 'HTTP/1.1 301 Moved Permanently\r\n' ③ -header: Date: Thu, 15 Apr 2004 22:06:25 GMT -header: Server: Apache/2.0.49 (Debian GNU/Linux) -header: Location: http://diveintomark.org/xml/atom.xml ④ -header: Content-Length: 338 -header: Connection: close -header: Content-Type: text/html; charset=iso-8859-1 -connect: (diveintomark.org, 80) -send: ' -GET /xml/atom.xml HTTP/1.0 ⑤ -Host: diveintomark.org -User-agent: Python-urllib/2.1 -' -reply: 'HTTP/1.1 200 OK\r\n' -header: Date: Thu, 15 Apr 2004 22:06:25 GMT -header: Server: Apache/2.0.49 (Debian GNU/Linux) -header: Last-Modified: Thu, 15 Apr 2004 19:45:21 GMT -header: ETag: "e842a-3e53-55d97640" -header: Accept-Ranges: bytes -header: Content-Length: 15955 -header: Connection: close -header: Content-Type: application/atom+xml ->>> f.url ⑥ -'http://diveintomark.org/xml/atom.xml' ->>> f.headers.dict -{'content-length': '15955', -'accept-ranges': 'bytes', -'server': 'Apache/2.0.49 (Debian GNU/Linux)', -'last-modified': 'Thu, 15 Apr 2004 19:45:21 GMT', -'connection': 'close', -'etag': '"e842a-3e53-55d97640"', -'date': 'Thu, 15 Apr 2004 22:06:25 GMT', -'content-type': 'application/atom+xml'} ->>> f.status -Traceback (most recent call last): - File "<stdin>", line 1, in ? -AttributeError: addinfourl instance has no attribute 'status' --
|