urllib.py 684 B

1234567891011121314151617181920212223
  1. from urllib2 import *
  2. class LessStrictHTTPErrorProcessor(HTTPErrorProcessor):
  3. """
  4. A urllib2 HTTP error processor which does not raise an error
  5. on HTTP 201 (created) or 202 (accepted) response.
  6. Used by HTTP push server when replying to a publisher.
  7. """
  8. def http_error_201(self, request, fp, code, msg, hdrs):
  9. """
  10. Does not raise an error on HTTP 201 (created) response.
  11. """
  12. return fp
  13. def http_error_202(self, request, fp, code, msg, hdrs):
  14. """
  15. Does not raise an error on HTTP 202 (accepted) response.
  16. """
  17. return fp
  18. opener = build_opener(LessStrictHTTPErrorProcessor)
  19. install_opener(opener)