request.py 750 B

12345678910111213141516171819202122
  1. from .common import unpickle_args
  2. try:
  3. import urllib.parse as urllib_parse #for python 3
  4. except ImportError:
  5. import urlparse as urllib_parse
  6. class Request(object):
  7. def __init__(self, url, handle):
  8. #: The entire request url.
  9. self.url = url
  10. #: The current request's handle, an integer.
  11. self.handle = int(handle)
  12. # urlparse doesn't like the 'plugin' scheme, so pass a protocol
  13. # relative url, e.g. //plugin.video.helloxbmc/path
  14. self.scheme, remainder = url.split(':', 1)
  15. parts = urllib_parse.urlparse(remainder)
  16. self.netloc, self.path, self.query_string = (parts[1], parts[2], parts[4])
  17. self.args = unpickle_args(urllib_parse.parse_qs(self.query_string))