im trying to make something like a feed reader. Im using feedparser.py
to parse the feeds like this
def fetch_feed(url, modified = None, etag = None):
import feedparser
headers = {}
if modified:
headers['If-Modified-Since'] = modified
if etag:
headers['If-None-Match'] = etag
response = urlfetch.fetch(url, headers = headers)
feed = feedparser.parse(response.content)
feed.modified = response.headers['Last-Modified'] if 'Last-
Modified' in response.headers else None
feed.etag = response.headers['ETag'] if 'ETag' in
response.headers else None
feed.status = response.status_code
return feed
but the If-Modified-Since and If-None-Match headers dont seem to work
on some feeds.. so i tried a test on http://shell.appspot.com/
>>> from google.appengine.api import urlfetch
>>> r = urlfetch.fetch('http://www.scripting.com/rss.xml')
>>> r.headers
{'Content-Length': '48035', 'Via': 'HTTP/1.1 GWA (remote cache hit)',
'Accept-Ranges': 'bytes', 'X-Google-Cache-Control': 'remote-cache-
hit', 'Server': 'Apache/2.2.4 (Win32)', 'Last-Modified': 'Fri, 30 Jan
2009 03:38:05 GMT', 'ETag': '"1dd8-bba3-eec4f564"', 'Date': 'Sun, 01
Feb 2009 04:46:09 GMT', 'Content-Type': 'application/xml', 'Age': '
14856'}
>>> h = r.headers
>>> r = urlfetch.fetch('http://www.scripting.com/rss.xml', headers =
>>> {'If-Modified-Since': h['Last-Modified'], 'If-None-Match': h['ETag']})
>>> r.status_code
200L
but if i do curl for the same i get a 304 http code as expected..
$ curl --head http://www.scripting.com/rss.xml
HTTP/1.1 200 OK
Date: Sun, 01 Feb 2009 08:58:24 GMT
Server: Apache/2.2.4 (Win32)
Last-Modified: Fri, 30 Jan 2009 03:38:05 GMT
ETag: "1dd8-bba3-eec4f564"
Accept-Ranges: bytes
Content-Length: 48035
Content-Type: application/xml
$ curl --head --header "If-Modified-Since: Fri, 30 Jan 2009 03:38:05
GMT" --header "If-None-Match: \"1dd8-bba3-eec4f564\""
http://www.scripting.com/rss.xml
HTTP/1.1 304 Not Modified
Date: Sun, 01 Feb 2009 08:58:16 GMT
Server: Apache/2.2.4 (Win32)
ETag: "1dd8-bba3-eec4f564"
Can some one help me with this.. am i doing anything wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---