Send raw string to the server.

        The string will be padded with appropriate CR LF.
160408
def send_raw(self, string):
        
        if self.socket is None:
            raise ServerNotConnectedError("Not connected.")
        sender = getattr(self.socket, 'write', self.socket.send)
        try:
            sender(self._prep_message(string))
            log.debug("TO SERVER: %s", string)
        except socket.error:
            # Ouch!
            self.disconnect("Connection reset by peer.")
464401
def _transfer_str(self, conn, tmp, name, data):
        '''  '''

        if type(data) == dict:
            data = utils.jsonify(data)

        afd, afile = tempfile.mkstemp()
        afo = os.fdopen(afd, 'w')
        try:
            afo.write(data.encode('utf8'))
        except:
            raise errors.AnsibleError("failure encoding into utf-8")
        afo.flush()
        afo.close()

        remote = os.path.join(tmp, name)
        try:
            conn.put_file(afile, remote)
        finally:
            os.unlink(afile)
        return remote
911289
def handle_string(self, strreq):
        '''
        
        '''

        #convert to jsonrpc-dict
        req = None
        try:
            req = json.loads(strreq)
        except:
            logging.debug('JSONRPC: Format Exception:')
            logging.debug('-----------------\n' + traceback.format_exc())
            return json.dumps(SLOJSONRPCError(-32700).to_json())

        #handle single request
        if isinstance(req, dict):
            return json.dumps(self.handle_request(req))
        #handle multiple requests
        elif isinstance(req, list):
            for r in req:
                if not isinstance(r, dict):
                    logging.debug('JSONRPC: Fmt Error: Item ' +
                                  '"%s" in request is no dictionary.' % str(r))
                    return json.dumps(SLOJSONRPCError(-32700).to_json())
                try:
                    self._validate_format(r)
                    self._validate_params(r)
                except SLOJSONRPCError as e:
                    return json.dumps(e.to_json(r.get('id', None)))

            res = []
            for r in req:
                res.append(self.handle_request(r, validate=False))
            return json.dumps(res)
        #invalid request
        else:
            return json.dumps(SLOJSONRPCError(-32700).to_json())
59086
def _send(self, data):
        """"""
        try:
            self._sock.sendto(data.encode('ascii'), self._addr)
        except (socket.error, RuntimeError):
            # No time for love, Dr. Jones!
            pass
45911
def write_var_str(self, value, encoding: str = 'utf-8'):
        
        if isinstance(value, str):
            value = value.encode(encoding)
        self.write_var_int(len(value))
        self.write_bytes(value)
554748
def send(self, text):
        
        if text:
            self.send_buffer += text.replace('\n', '\r\n')
            self.send_pending = True
506895
def send(self, *args):
        
        msg = " ".join(a.nick if isinstance(a, User) else str(a) for a in args)
        if "\n" in msg:
            raise ValueError("Cannot send() a newline. Args: %s" % repr(args))
        _log.debug("%s <-- %s", self.server.host, msg)
        self.socket.send(msg + "\r\n")
275574
def send_stderr(cls, sock, payload):
    """"""
    cls.write_chunk(sock, ChunkType.STDERR, payload)
887892
def encode_string(str)
      str = str.to_s.encode('UTF-8')

      # Force to binary, when assembling the packet
      str.force_encoding('ASCII-8BIT')
      encode_short(str.bytesize) + str
    end
78400
def __sendString(self, string):
        
        logger.debug("Sending string: %r", string)
        # Determine if workaround is needed
        if not cm.ConfigManager.SETTINGS[cm.ENABLE_QT4_WORKAROUND]:
            self.__checkWorkaroundNeeded()

        # First find out if any chars need remapping
        remapNeeded = False
        for char in string:
            keyCodeList = self.localDisplay.keysym_to_keycodes(ord(char))
            usableCode, offset = self.__findUsableKeycode(keyCodeList)
            if usableCode is None and char not in self.remappedChars:
                remapNeeded = True
                break

        # Now we know chars need remapping, do it
        if remapNeeded:
            self.__ignoreRemap = True
            self.remappedChars = {}
            remapChars = []

            for char in string:
                keyCodeList = self.localDisplay.keysym_to_keycodes(ord(char))
                usableCode, offset = self.__findUsableKeycode(keyCodeList)
                if usableCode is None:
                    remapChars.append(char)

            logger.debug("Characters requiring remapping: %r", remapChars)
            availCodes = self.__availableKeycodes
            logger.debug("Remapping with keycodes in the range: %r", availCodes)
            mapping = self.localDisplay.get_keyboard_mapping(8, 200)
            firstCode = 8

            for i in range(len(availCodes) - 1):
                code = availCodes[i]
                sym1 = 0
                sym2 = 0

                if len(remapChars) > 0:
                    char = remapChars.pop(0)
                    self.remappedChars[char] = (code, 0)
                    sym1 = ord(char)
                if len(remapChars) > 0:
                    char = remapChars.pop(0)
                    self.remappedChars[char] = (code, 1)
                    sym2 = ord(char)

                if sym1 != 0:
                    mapping[code - firstCode][0] = sym1
                    mapping[code - firstCode][1] = sym2

            mapping = [tuple(l) for l in mapping]
            self.localDisplay.change_keyboard_mapping(firstCode, mapping)
            self.localDisplay.flush()

        focus = self.localDisplay.get_input_focus().focus

        for char in string:
            try:
                keyCodeList = self.localDisplay.keysym_to_keycodes(ord(char))
                keyCode, offset = self.__findUsableKeycode(keyCodeList)
                if keyCode is not None:
                    if offset == 0:
                        self.__sendKeyCode(keyCode, theWindow=focus)
                    if offset == 1:
                        self.__pressKey(Key.SHIFT)
                        self.__sendKeyCode(keyCode, self.modMasks[Key.SHIFT], focus)
                        self.__releaseKey(Key.SHIFT)
                    if offset == 4:
                        self.__pressKey(Key.ALT_GR)
                        self.__sendKeyCode(keyCode, self.modMasks[Key.ALT_GR], focus)
                        self.__releaseKey(Key.ALT_GR)
                    if offset == 5:
                        self.__pressKey(Key.ALT_GR)
                        self.__pressKey(Key.SHIFT)
                        self.__sendKeyCode(keyCode, self.modMasks[Key.ALT_GR]|self.modMasks[Key.SHIFT], focus)
                        self.__releaseKey(Key.SHIFT)
                        self.__releaseKey(Key.ALT_GR)

                elif char in self.remappedChars:
                    keyCode, offset = self.remappedChars[char]
                    if offset == 0:
                        self.__sendKeyCode(keyCode, theWindow=focus)
                    if offset == 1:
                        self.__pressKey(Key.SHIFT)
                        self.__sendKeyCode(keyCode, self.modMasks[Key.SHIFT], focus)
                        self.__releaseKey(Key.SHIFT)
                else:
                    logger.warning("Unable to send character %r", char)
            except Exception as e:
                logger.exception("Error sending char %r: %s", char, str(e))

        self.__ignoreRemap = False
542695
function sendText (req, res, next, data) {
  setContentType(req, res,
    ["text", "html", "text/*", "application/*"],                // allow these types
    ["json", "*/json", "+json", "application/octet-stream"]);   // don't allow these types

  util.debug("Serializing the response as a string");
  res.send(_(data).toString());
}
547460
def send(self, target, nick, msg, msgtype, ignore_length=False, filters=None):
        
        if not isinstance(msg, str):
            raise Exception("Trying to send a %s to irc, only strings allowed." % type(msg).__name__)
        if filters is None:
            filters = self.outputfilter[target]
        for i in filters:
            if target != self.config['core']['ctrlchan']:
                msg = i(msg)
        # Avoid spam from commands that produce excessive output.
        if not ignore_length:
            # Ignore everything after the first 800 chars.
            msg = misc.truncate_msg(msg, 800)

        # We can't send messages > 512 bytes to irc.
        max_len = misc.get_max_length(target, msgtype)
        msgs = self.build_split_msg(msg, max_len)

        for i in msgs:
            self.do_log(target, nick, i, msgtype)
            if msgtype == 'action':
                self.rate_limited_send('action', target, i)
            else:
                self.rate_limited_send('privmsg', target, i)
171902
def write_string(self, value, length):
        """"""
        format = '!' + str(length) + 's'
        self.data.append(struct.pack(format, value))
        self.size += length
414435
public function send()
    {
        $data = $this->parseDataToString($this->data);
        $format = $this->allowedFormats[$this->format];

        // Send status header
        header($this->getStatus(), true, $this->getStatus());

        foreach(self::$headers as $key => $value) {
            header($key.": ".$value);
        }

        // Send content type header
        header("Content-Type: ".$format['mimetype']."; charset=utf-8");

		// Set content length header
		header("Content-Length: ".strlen($data));

        if(function_exists("ginger_log")) {
            ginger_log($this);
        }

        echo $data;

        die();
    }
1229108
def send_post(config, urlpath, post_data):
    '''
    
    '''
    server = config.get("Server", "url")
    logger.debug("Sending executor payload to " + server)
    post_data = urlencode(post_data)
    post_data = post_data.encode("utf-8", errors="ignore")
    url = server + urlpath
    try:
        urlopen(url, post_data)
    except Exception as e:
        logger.error('Error while sending data to server: ' + str(e))
504027
def _write_transport(self, string):
        """"""
        if isinstance(string, str):  # we need to convert to bytes
            self.transport.write(string.encode('utf-8'))
        else:
            self.transport.write(string)
812563
private void consumeCRLF(ImapRequestLineReader request)
            throws ProtocolException {
        char next = request.nextChar();
        if (next != '\n') {
            consumeChar(request, '\r');
        }
        consumeChar(request, '\n');
    }