MCPcopy Create free account
hub / github.com/StackStorm/st2 / __init__

Method __init__

st2common/st2common/router.py:176–204  ·  view source on GitHub ↗
(
        self,
        body=None,
        status=None,
        headerlist=None,
        app_iter=None,
        content_type=None,
        *args,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

174 """
175
176 def __init__(
177 self,
178 body=None,
179 status=None,
180 headerlist=None,
181 app_iter=None,
182 content_type=None,
183 *args,
184 **kwargs,
185 ):
186 # Do some sanity checking, and turn json_body into an actual body
187 if (
188 app_iter is None
189 and body is None
190 and ("json_body" in kwargs or "json" in kwargs)
191 ):
192 if "json_body" in kwargs:
193 json_body = kwargs.pop("json_body")
194 else:
195 json_body = kwargs.pop("json")
196
197 body = json_encode(json_body).encode("utf-8")
198
199 if content_type is None:
200 content_type = "application/json"
201
202 super(Response, self).__init__(
203 body, status, headerlist, app_iter, content_type, *args, **kwargs
204 )
205
206 def _json_body__get(self):
207 return json_decode(self.body.decode(self.charset or "utf-8"))

Callers

nothing calls this directly

Calls 3

json_encodeFunction · 0.90
popMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected