MCPcopy Create free account
hub / github.com/dbcli/mssql-cli / send_request

Method send_request

mssqlcli/jsonrpc/jsonrpcclient.py:201–225  ·  view source on GitHub ↗

Send JSON RPC request message. Exceptions raised: ValueError If the stream was closed externally.

(self, method, params, request_id=None)

Source from the content-addressed store, hash-verified

199 self.encoding = encoding or u'UTF-8'
200
201 def send_request(self, method, params, request_id=None):
202 """
203 Send JSON RPC request message.
204 Exceptions raised:
205 ValueError
206 If the stream was closed externally.
207 """
208 # Perhaps move to a different def to add some validation
209 content_body = {
210 u'jsonrpc': u'2.0',
211 u'method': method,
212 u'params': params,
213 u'id': request_id
214 }
215
216 json_content = json.dumps(content_body, sort_keys=True)
217 header = self.HEADER.format(str(len(json_content)))
218 try:
219 self.stream.write(header.encode(u'ascii'))
220 self.stream.write(json_content.encode(self.encoding))
221 self.stream.flush()
222
223 except ValueError as ex:
224 logger.debug(u'Send Request encountered exception %s', ex)
225 raise
226
227 def close(self):
228 """

Calls 2

writeMethod · 0.80
formatMethod · 0.45