Encode request into client_message
6597
def encode_request(timeout, durability, transaction_type, thread_id):
    
    client_message = ClientMessage(payload_size=calculate_size(timeout, durability, transaction_type, thread_id))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_long(timeout)
    client_message.append_int(durability)
    client_message.append_int(transaction_type)
    client_message.append_long(thread_id)
    client_message.update_frame_length()
    return client_message
401037
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    response_size = client_message.read_int()
    response = []
    for _ in range(0, response_size):
        response_item = client_message.read_data()
        response.append(response_item)
    parameters['response'] = ImmutableLazyDataList(response, to_object)
    return parameters
262874
def encode(self, envelope, session, **kwargs):
		
		return WMessengerTextEnvelope(str(WHex(envelope.message())), meta=envelope)
586524
def encode_request(uuid, address, interrupt):
    
    client_message = ClientMessage(payload_size=calculate_size(uuid, address, interrupt))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(uuid)
    AddressCodec.encode(client_message, address)
    client_message.append_bool(interrupt)
    client_message.update_frame_length()
    return client_message
719799
def to_mime_message(self):
        """"""
        msg = MIMEMultipart('alternative')
        msg['Subject'] = self._header(self._subject or '')

        msg['From'] = self._encoded(self._addrs_to_header([self._from]))
        msg['To'] = self._encoded(self._addrs_to_header(self._to))

        if self._cc:
            msg['CC'] = self._addrs_to_header(self._cc)

        if self._headers:
            for key, value in self._headers.items():
                msg[key] = self._header(value)

        for part in self._parts:
            type_maj, type_min = part[0].split('/')
            if type_maj == 'text' and type_min in ('html', 'plain'):
                msg.attach(MIMEText(part[1], type_min, self._charset))
            else:
                msg.attach(part[1])

        return msg
717973
def _get_request_messages(self, request):
        
        data = request.get_data(as_text=True)
        try:
            msg = self.json_decoder.decode(data)
        except Exception:
            raise ParseError("Could not parse request data '{}'".format(data))
        if isinstance(msg, list):
            return msg
        else:
            return [msg]
1199128
def encode(self, delimiter=';'):
        """"""
        try:
            return delimiter.join([str(f) for f in [
                self.node_id,
                self.child_id,
                int(self.type),
                self.ack,
                int(self.sub_type),
                self.payload,
            ]]) + '\n'
        except ValueError:
            _LOGGER.error('Error encoding message to gateway')
1175553
def _encode_payload(data, headers=None):
    ""
    prolog = "CONTENT_LENGTH\0%d\0SCGI\x001\0" % len(data)
    if headers:
        prolog += _encode_headers(headers)

    return _encode_netstring(prolog) + data
951396
function encodeParams(params) {
    var queryString;
    if (params && Object.keys(params)) {
        queryString = [].slice.call(arguments).reduce(function (a, b) {
            return a.concat(b instanceof Array ? b : [b]);
        }, []).filter(function (c) {
            return "object" === typeof c;
        }).reduce(function (p, c) {
            !(c instanceof Array) ? p = p.concat(Object.keys(c).map(function (key) {
                return [key, c[key]];
            })) : p.push(c);
            return p;
        }, []).reduce(function (p, c) {
            c.length === 2 ? p.push(c) : p = p.concat(c);
            return p;
        }, []).reduce(function (p, c) {
            c[1] instanceof Array ? c[1].forEach(function (v) {
                p.push([c[0], v]);
            }) : p.push(c);
            return p;
        }, []).map(function (c) {
            c[1] = encodeURIComponent(c[1]);
            return c.join("=");
        }).join("&");
    }
    return queryString;
}
961466
def clientCutText(self, message):
        
        self.transport.write(pack("!BxxxI", 6, len(message)) + message)
1037422
def encode_base64(msg):
    
    orig = msg.get_payload()
    encdata = str(_bencode(orig), 'ascii')
    msg.set_payload(encdata)
    msg['Content-Transfer-Encoding'] = 'base64'
781189
def request(url, message):
    """"""
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    host, port = url.split(':')
    port = int(port)
    s.connect((host, port))
    s.send(pack(message))
    data = s.makefile().read()
    s.close()
    return data
367821
def build_request(headers: Headers) -> str:
    
    raw_key = bytes(random.getrandbits(8) for _ in range(16))
    key = base64.b64encode(raw_key).decode()
    headers["Upgrade"] = "websocket"
    headers["Connection"] = "Upgrade"
    headers["Sec-WebSocket-Key"] = key
    headers["Sec-WebSocket-Version"] = "13"
    return key
335734
def _encode_request(self, request):
        """"""
        return pickle.dumps(request_to_dict(request, self.spider), protocol=-1)
162139
def encode(cls, d):
        
        warnings.warn(
            'The `encode` class method of APIRequestor is deprecated and '
            'will be removed in version 2.0.'
            'If you need public access to this function, please email us '
            'at support@stripe.com.',
            DeprecationWarning)
        return urllib.urlencode(list(_api_encode(d)))
285858
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    parameters['response'] = client_message.read_long()
    return parameters
1347904
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    parameters['response'] = client_message.read_str()
    return parameters