http-other.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Other :abbr:`HTTP (Hypertext Transfer Protocol)` Headers
  2. ========================================================
  3. You can specify additional :abbr:`HTTP (Hypertext Transfer Protocol)` request
  4. headers as a dictionary. When you download a feed from a remote web server,
  5. :program:`Universal Feed Parser` exposes the complete set of
  6. :abbr:`HTTP (Hypertext Transfer Protocol)` response headers as a dictionary.
  7. .. _example.http.headers.request:
  8. Sending custom :abbr:`HTTP (Hypertext Transfer Protocol)` request headers
  9. -------------------------------------------------------------------------
  10. ::
  11. >>> import feedparser
  12. >>> d = feedparser.parse('http://feedparser.org/docs/examples/atom03.xml',
  13. request_headers={'Cache-control': 'max-age=0'})
  14. Accessing other :abbr:`HTTP (Hypertext Transfer Protocol)` response headers
  15. ---------------------------------------------------------------------------
  16. ::
  17. >>> import feedparser
  18. >>> d = feedparser.parse('http://feedparser.org/docs/examples/atom03.xml')
  19. >>> d.headers
  20. {'date': 'Fri, 11 Jun 2004 23:57:50 GMT',
  21. 'server': 'Apache/2.0.49 (Debian GNU/Linux)',
  22. 'last-modified': 'Fri, 11 Jun 2004 23:00:34 GMT',
  23. 'etag': '"6c132-941-ad7e3080"',
  24. 'accept-ranges': 'bytes',
  25. 'vary': 'Accept-Encoding,User-Agent',
  26. 'content-encoding': 'gzip',
  27. 'content-length': '883',
  28. 'connection': 'close',
  29. 'content-type': 'application/xml'}