MCPcopy Create free account
hub / github.com/comaps/comaps / Payload

Class Payload

tools/python/test_server/server/ResponseProvider.py:11–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class Payload:
12 def __init__(self, message, response_code=200, headers={}):
13 self.__response_code = response_code
14 self.__message = message if type(message) is bytes else message.encode('utf8')
15 self.__headers = headers
16
17
18 def response_code(self):
19 """
20 Response code to send to the client.
21 """
22 return self.__response_code
23
24
25 def message(self):
26 """
27 The message to send to the client.
28 """
29 return self.__message
30
31
32 def length(self):
33 """
34 The length of the response.
35 """
36 return len(self.message())
37
38
39 def headers(self):
40 """
41 The headers to be sent to the client. Please, note, that these do not include
42 the Content-Length header, which you need to send separately.
43 """
44 return self.__headers
45
46
47 def __repr__(self):
48 return "{}: {}: {}".format(self.response_code(), self.length(), self.message())
49
50
51class ResponseProviderMixin:

Callers 15

postMethod · 0.90
do_POSTMethod · 0.90
pongMethod · 0.85
my_idMethod · 0.85
test1Method · 0.85
test_404Method · 0.85
test_301Method · 0.85
test_47_kbMethod · 0.85
partners_timeMethod · 0.85
partners_priceMethod · 0.85

Calls

no outgoing calls

Tested by 4

do_POSTMethod · 0.72
test_404Method · 0.68
test_301Method · 0.68
test_47_kbMethod · 0.68