class request(object_ref): def __init__(self, url, callback=none, method='get', headers=none, body=none, COOKIEs=none, meta=none, encoding='utf-8', priority=0, dont_filter=false, errback=none, flags=none, cb_kwargs=none): self._encoding = encoding # this one has to be set first self.method = str(method).upper() self._set_url(url) self._set_body(body) if not isinstance(priority, int): raise typeerror(f"request priority not an integer: {priority!r}") self.priority = priority if callback is not none and not callable(callback): raise typeerror(f'callback must be a callable, got {type(callback).__name__}') if errback is not none and not callable(errback): raise typeerror(f'errback must be a callable, got {type(errback).__name__}') self.callback = callback self.errback = errback self.COOKIEs = COOKIEs or {} self.headers = headers(headers or {}, encoding=encoding) self.dont_filter = dont_filter self._meta = dict(meta) if meta else none self._cb_kwargs = dict(cb_kwargs) if cb_kwargs else none self.flags = [] if flags is none else list(flags)