MCPcopy
hub / github.com/scrapy/scrapy / __init__

Method __init__

scrapy/http/request/form.py:52–71  ·  view source on GitHub ↗
(
        self, *args: Any, formdata: FormdataType = None, **kwargs: Any
    )

Source from the content-addressed store, hash-verified

50 valid_form_methods: ClassVar[list[str]] = ["GET", "POST"]
51
52 def __init__(
53 self, *args: Any, formdata: FormdataType = None, **kwargs: Any
54 ) -> None:
55 if formdata and kwargs.get("method") is None:
56 kwargs["method"] = "POST"
57
58 super().__init__(*args, **kwargs)
59
60 if formdata:
61 items = formdata.items() if isinstance(formdata, dict) else formdata
62 form_query_str = _urlencode(items, self.encoding)
63 if self.method == "POST":
64 self.headers.setdefault(
65 b"Content-Type", b"application/x-www-form-urlencoded"
66 )
67 self._set_body(form_query_str)
68 else:
69 self._set_url(
70 urlunsplit(urlsplit(self.url)._replace(query=form_query_str))
71 )
72
73 @classmethod
74 def from_response(

Callers

nothing calls this directly

Calls 6

_urlencodeFunction · 0.85
itemsMethod · 0.80
getMethod · 0.45
setdefaultMethod · 0.45
_set_bodyMethod · 0.45
_set_urlMethod · 0.45

Tested by

no test coverage detected