

def send(self, data):
    "Send `data' to the server.\n        ``data`` can be a string object, a bytes object, an array object, a\n        file-like object that supports a .read() method, or an iterable object.\n        "
    if (self.sock is None):
        if self.auto_open:
            self.connect()
        else:
            raise NotConnected()
    if (self.debuglevel > 0):
        print('send:', repr(data))
    blocksize = 8192
    if (hasattr(data, 'read') and (not isinstance(data, array))):
        if (self.debuglevel > 0):
            print('sendIng a read()able')
        encode = False
        try:
            mode = data.mode
        except AttributeError:
            pass
        else:
            if ('b' not in mode):
                encode = True
                if (self.debuglevel > 0):
                    print('encoding file using iso-8859-1')
        while 1:
            datablock = data.read(blocksize)
            if (not datablock):
                break
            if encode:
                datablock = datablock.encode('iso-8859-1')
            self.sock.sendall(datablock)
        return
    try:
        self.sock.sendall(data)
    except TypeError:
        if isinstance(data, collections.Iterable):
            for d in data:
                self.sock.sendall(d)
        else:
            raise TypeError(('data should be a bytes-like object or an iterable, got %r' % type(data)))

dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/future/backports/http/client.py HTTPConnection.send/original