MCPcopy Index your code
hub / github.com/RustPython/RustPython / send

Method send

Lib/http/client.py:1049–1084  ·  view source on GitHub ↗

Send 'data' to the server. ``data`` can be a string object, a bytes object, an array object, a file-like object that supports a .read() method, or an iterable object.

(self, data)

Source from the content-addressed store, hash-verified

1047 response.close()
1048
1049 def send(self, data):
1050 """Send 'data' to the server.
1051 ``data`` can be a string object, a bytes object, an array object, a
1052 file-like object that supports a .read() method, or an iterable object.
1053 """
1054
1055 if self.sock is None:
1056 if self.auto_open:
1057 self.connect()
1058 else:
1059 raise NotConnected()
1060
1061 if self.debuglevel > 0:
1062 print("send:", repr(data))
1063 if hasattr(data, "read") :
1064 if self.debuglevel > 0:
1065 print("sending a readable")
1066 encode = self._is_textIO(data)
1067 if encode and self.debuglevel > 0:
1068 print("encoding file using iso-8859-1")
1069 while datablock := data.read(self.blocksize):
1070 if encode:
1071 datablock = datablock.encode("iso-8859-1")
1072 sys.audit("http.client.send", self, datablock)
1073 self.sock.sendall(datablock)
1074 return
1075 sys.audit("http.client.send", self, data)
1076 try:
1077 self.sock.sendall(data)
1078 except TypeError:
1079 if isinstance(data, collections.abc.Iterable):
1080 for d in data:
1081 self.sock.sendall(d)
1082 else:
1083 raise TypeError("data should be a bytes-like object "
1084 "or an iterable, got %r" % type(data))
1085
1086 def _output(self, s):
1087 """Add a line of output to the current request buffer.

Callers 5

_tunnelMethod · 0.95
_send_outputMethod · 0.95
test_sendMethod · 0.95
test_blocksize_sendMethod · 0.95

Calls 10

connectMethod · 0.95
_is_textIOMethod · 0.95
NotConnectedClass · 0.85
reprFunction · 0.85
hasattrFunction · 0.85
isinstanceFunction · 0.85
printFunction · 0.50
readMethod · 0.45
encodeMethod · 0.45
sendallMethod · 0.45

Tested by 3

test_sendMethod · 0.76
test_blocksize_sendMethod · 0.76