| 121 | del __attrs_and_slots |
| 122 | |
| 123 | def __init__( |
| 124 | self, |
| 125 | url: str, |
| 126 | callback: CallbackT | None = None, |
| 127 | method: str = "GET", |
| 128 | headers: Mapping[AnyStr, Any] | Iterable[tuple[AnyStr, Any]] | None = None, |
| 129 | body: bytes | str | None = None, |
| 130 | cookies: CookiesT | None = None, |
| 131 | meta: dict[str, Any] | None = None, |
| 132 | encoding: str = "utf-8", |
| 133 | priority: int = 0, |
| 134 | dont_filter: bool = False, |
| 135 | errback: Callable[[Failure], Any] | None = None, |
| 136 | flags: list[str] | None = None, |
| 137 | cb_kwargs: dict[str, Any] | None = None, |
| 138 | ) -> None: |
| 139 | self._encoding: str = encoding # this one has to be set first |
| 140 | self.method: str = str(method).upper() |
| 141 | self._set_url(url) |
| 142 | self._set_body(body) |
| 143 | if not isinstance(priority, int): |
| 144 | raise TypeError(f"Request priority not an integer: {priority!r}") |
| 145 | |
| 146 | #: Default: ``0`` |
| 147 | #: |
| 148 | #: Value that the :ref:`scheduler <topics-scheduler>` may use for |
| 149 | #: request prioritization. |
| 150 | #: |
| 151 | #: Built-in schedulers prioritize requests with a higher priority |
| 152 | #: value. |
| 153 | #: |
| 154 | #: Negative values are allowed. |
| 155 | self.priority: int = priority |
| 156 | |
| 157 | if not (callable(callback) or callback is None): |
| 158 | raise TypeError( |
| 159 | f"callback must be a callable, got {type(callback).__name__}" |
| 160 | ) |
| 161 | if not (callable(errback) or errback is None): |
| 162 | raise TypeError(f"errback must be a callable, got {type(errback).__name__}") |
| 163 | |
| 164 | #: :class:`~collections.abc.Callable` to parse the |
| 165 | #: :class:`~scrapy.http.Response` to this request once received. |
| 166 | #: |
| 167 | #: The callable must expect the response as its first parameter, and |
| 168 | #: support any additional keyword arguments set through |
| 169 | #: :attr:`cb_kwargs`. |
| 170 | #: |
| 171 | #: In addition to an arbitrary callable, the following values are also |
| 172 | #: supported: |
| 173 | #: |
| 174 | #: - ``None`` (default), which indicates that the |
| 175 | #: :meth:`~scrapy.Spider.parse` method of the spider must be used. |
| 176 | #: |
| 177 | #: - :func:`~scrapy.http.request.NO_CALLBACK`. |
| 178 | #: |
| 179 | #: If an unhandled exception is raised during request or response |
| 180 | #: processing, i.e. by a :ref:`spider middleware |