A user-created :class:`Request <Request>` object. Used to prepare a :class:`PreparedRequest <PreparedRequest>`, which is sent to the server. :param method: HTTP method to use. :param url: URL to send. :param headers: dictionary of headers to send. :param files: dictionary of {f
| 281 | |
| 282 | |
| 283 | class Request(RequestHooksMixin): |
| 284 | """A user-created :class:`Request <Request>` object. |
| 285 | |
| 286 | Used to prepare a :class:`PreparedRequest <PreparedRequest>`, which is sent to the server. |
| 287 | |
| 288 | :param method: HTTP method to use. |
| 289 | :param url: URL to send. |
| 290 | :param headers: dictionary of headers to send. |
| 291 | :param files: dictionary of {filename: fileobject} files to multipart upload. |
| 292 | :param data: the body to attach to the request. If a dictionary or |
| 293 | list of tuples ``[(key, value)]`` is provided, form-encoding will |
| 294 | take place. |
| 295 | :param json: json for the body to attach to the request (if files or data is not specified). |
| 296 | :param params: URL parameters to append to the URL. If a dictionary or |
| 297 | list of tuples ``[(key, value)]`` is provided, form-encoding will |
| 298 | take place. |
| 299 | :param auth: Auth handler or (user, pass) tuple. |
| 300 | :param cookies: dictionary or CookieJar of cookies to attach to this request. |
| 301 | :param hooks: dictionary of callback hooks, for internal usage. |
| 302 | |
| 303 | Usage:: |
| 304 | |
| 305 | >>> import requests |
| 306 | >>> req = requests.Request('GET', 'https://httpbin.org/get') |
| 307 | >>> req.prepare() |
| 308 | <PreparedRequest [GET]> |
| 309 | """ |
| 310 | |
| 311 | method: str | None |
| 312 | url: _t.UriType | None |
| 313 | headers: Mapping[str, str | bytes] |
| 314 | files: _t.FilesType |
| 315 | data: _t.DataType |
| 316 | json: _t.JsonType |
| 317 | params: _t.ParamsType |
| 318 | auth: _t.AuthType |
| 319 | cookies: RequestsCookieJar | CookieJar | dict[str, str] | None |
| 320 | |
| 321 | def __init__( |
| 322 | self, |
| 323 | method: str | None = None, |
| 324 | url: _t.UriType | None = None, |
| 325 | headers: _t.HeadersType = None, |
| 326 | files: _t.FilesType = None, |
| 327 | data: _t.DataType = None, |
| 328 | params: _t.ParamsType = None, |
| 329 | auth: _t.AuthType = None, |
| 330 | cookies: RequestsCookieJar | CookieJar | dict[str, str] | None = None, |
| 331 | hooks: _t.HooksInputType | None = None, |
| 332 | json: _t.JsonType = None, |
| 333 | ) -> None: |
| 334 | # Default empty dicts for dict params. |
| 335 | data = [] if data is None else data |
| 336 | files = [] if files is None else files |
| 337 | headers = {} if headers is None else headers |
| 338 | params = {} if params is None else params |
| 339 | hooks = {} if hooks is None else hooks |
| 340 |