request.py 881 B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. class TeaRequest(object):
  3. _PROPERTY_DEFAULT_MAP = {
  4. 'query': {},
  5. 'protocol': 'http',
  6. 'port': 80,
  7. 'method': 'GET',
  8. 'headers': {},
  9. 'pathname': "",
  10. 'body': None,
  11. }
  12. def __init__(self):
  13. self.query = {}
  14. self.protocol = "http"
  15. self.port = 80
  16. self.method = "GET"
  17. self.headers = {}
  18. self.pathname = ""
  19. self.body = None
  20. def __setattr__(self, key, value):
  21. if key in self._PROPERTY_DEFAULT_MAP:
  22. if not value:
  23. if isinstance(self._PROPERTY_DEFAULT_MAP[key], (list, dict)):
  24. self.__dict__[key] = self._PROPERTY_DEFAULT_MAP[key].copy()
  25. else:
  26. self.__dict__[key] = self._PROPERTY_DEFAULT_MAP[key]
  27. return
  28. self.__dict__[key] = value