MCPcopy
hub / github.com/django/django / _base_scope

Method _base_scope

django/test/client.py:689–717  ·  view source on GitHub ↗

The base scope for a request.

(self, **request)

Source from the content-addressed store, hash-verified

687 """
688
689 def _base_scope(self, **request):
690 """The base scope for a request."""
691 # This is a minimal valid ASGI scope, plus:
692 # - headers['cookie'] for cookie support,
693 # - 'client' often useful, see #8551.
694 scope = {
695 "asgi": {"version": "3.0"},
696 "type": "http",
697 "http_version": "1.1",
698 "client": ["127.0.0.1", 0],
699 "server": ("testserver", "80"),
700 "scheme": "http",
701 "method": "GET",
702 "headers": [],
703 **self.defaults,
704 **request,
705 }
706 scope["headers"].append(
707 (
708 b"cookie",
709 b"; ".join(
710 sorted(
711 ("%s=%s" % (morsel.key, morsel.coded_value)).encode("ascii")
712 for morsel in self.cookies.values()
713 )
714 ),
715 )
716 )
717 return scope
718
719 def request(self, **request):
720 """Construct a generic request object."""

Calls 4

appendMethod · 0.45
joinMethod · 0.45
encodeMethod · 0.45
valuesMethod · 0.45