Write data to the apn stream that is associated with the given apn URL

@param  string            $apnURL
@param  string            $payload
@throws \RuntimeException
@return mixed
356808
protected function writeApnStream($apnURL, $payload)
    {
        // Get the correct Apn stream and send data
        $fp = $this->getApnStream($apnURL);
        $response = (strlen($payload) === @fwrite($fp, $payload, strlen($payload)));

        // Check if there is responsedata to read
        $readStreams = array($fp);
        $null = NULL;
        $streamsReadyToRead = @stream_select($readStreams, $null, $null, 1, 0);
        if ($streamsReadyToRead > 0) {
            // Unpack error response data and set as the result
            $response = @unpack("Ccommand/Cstatus/Nidentifier", fread($fp, 6));
            $this->closeApnStream($apnURL);
        }

        // Will contain true if writing succeeded and no error is returned yet
        return $response;
    }
425857
public function execute(array $payload): JsonResponse
    {
        $challenge = $payload['challenge'] ?? null;
        if ($challenge) {
            return new JsonResponse(['challenge' => $challenge]);
        }

        throw new RuntimeException();
    }
1348584
private function performCurlSession($payload)
    {
        $perCurlConnection = curl_init();
        curl_setopt($perCurlConnection, CURLOPT_URL, $this->url);
        curl_setopt($perCurlConnection, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($perCurlConnection, CURLOPT_TIMEOUT, 10);
        curl_setopt($perCurlConnection, CURLOPT_POSTFIELDS, $payload);

        $result = curl_exec($perCurlConnection);

        return $result;
    }
274019
private function writePayloadOnStreamForGivenToken($payload, $stream, $token)
    {
        $binaryMessage = sprintf('%s%s%s%s%s',
            chr(0),
            pack('n', 32),
            pack('H*', str_replace(' ', '', $token)),
            pack('n', strlen($payload)),
            $payload
        );

        fwrite($stream, $binaryMessage, strlen($binaryMessage));
    }
453394
public Optional<Response> POST(String partialUrl, Object payload)
    {    
        URI uri = buildUri(partialUrl);   
        return executePostRequest(uri, payload);
    }
1007477
public function encode(Payload $payload)
    {
        $token = $this->jwt->encode($payload->get());

        return new Token($token);
    }
1097485
public function pushRaw($payload, $queue = null, array $options = [])
    {
        $this->getConnection()->rPush($this->getQueue($queue), $payload);

        return Arr::get(json_decode($payload, true), 'id');
    }
73922
public function pushRaw($payload, $queue = null, array $options = [])
    {
        return $this->swoole->task($payload, ! is_numeric($queue) ? -1 : (int)$queue);
    }
1121321
function post($path = null, $postBody = null, $headers = null, $curlOpts = null) {
        $payload = $this -> encodePostBody($postBody);
        $this -> log -> debug("\n\n ====== Dump the payload before Http POST send! ====== \n\n$payload\n\n====== End Dump! ======\n");
        return $this -> request($path, self::HTTP_POST, $payload, $headers, $curlOpts);
    }
1109052
public function sendSoap($payload)
    {
        $options = [
            CURLOPT_URL            => $this->getUrl(),
            CURLOPT_CONNECTTIMEOUT => 5,
            CURLOPT_TIMEOUT        => 5,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST           => true,
            CURLOPT_POSTFIELDS     => $payload,
            CURLOPT_SSLVERSION     => CURL_SSLVERSION_TLSv1_2,
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_CAINFO         => $this->getRootCertificatePath(),
        ];

        $curlHandle = curl_init();
        curl_setopt_array($curlHandle, $options);

        $this->setLastRequest($payload);

        $response = curl_exec($curlHandle);
        $code = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
        $error = curl_error($curlHandle);

        $this->setErrorCode($code);
        $this->setLastResponse($response);

        curl_close($curlHandle);

        if ($response) {
            return $this->parseResponse($response, $code);
        } else {
            throw new Exception($error);
        }
    }
997404
protected function _createRequest(
    ApiPayloadInterface $payload = null, $path = null, $verb = HttpVerb::POST
  )
  {
    return parent::_createRequest($payload, $path, $verb);
  }
1354219
public static function put($uri, $payload = null, $mime = null)
    {
        return self::init(Http::PUT)->uri($uri)->body($payload, $mime);
    }
138563
private function processXmlResponse($url, $payload = '', $contentType = 'application/xml')
    {
        if (extension_loaded('curl')) {
            $ch = curl_init();
            if (!$ch) {
                throw new \RuntimeException('Unhandled curl error: ' . curl_error($ch));
            }
            $timeout = 10;

            // Needed to store the JSESSIONID
            $cookiefile     = tmpfile();
            $cookiefilepath = stream_get_meta_data($cookiefile)['uri'];

            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
            curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefilepath);
            curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefilepath);
            if (!empty($payload)) {
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
                curl_setopt($ch, CURLOPT_HTTPHEADER, [
                    'Content-type: ' . $contentType,
                    'Content-length: ' . mb_strlen($payload),
                ]);
            }
            $data = curl_exec($ch);
            if ($data === false) {
                throw new \RuntimeException('Unhandled curl error: ' . curl_error($ch));
            }
            curl_close($ch);

            $cookies = file_get_contents($cookiefilepath);
            if (strpos($cookies, 'JSESSIONID') !== false) {
                preg_match('/(?:JSESSIONID\s*)(?<JSESSIONID>.*)/', $cookies, $output_array);
                $this->setJSessionId($output_array['JSESSIONID']);
            }

            return new SimpleXMLElement($data);
        } else {
            throw new \RuntimeException('Post XML data set but curl PHP module is not installed or not enabled.');
        }
    }
1108357
public function sendPayload($payload, $callback)
    {
        if (!is_string($payload)) {
            throw new \InvalidArgumentException('Payload must be string.');
        }

        try {
            $res = $this->client->post($this->host, [
                'headers' => [
                    'content-type' => 'application/json'
                ],
                'body' => $payload,
                'timeout' => $this->timeout,
                'connect_timeout' => $this->timeout
            ]);
            /**
             * @var StreamInterface $stream ;
             */
            $stream = $res->getBody();
            $json = json_decode($stream);
            $stream->close();

            if (JSON_ERROR_NONE !== json_last_error()) {
                call_user_func($callback, new InvalidArgumentException('json_decode error: ' . json_last_error_msg()), null);
            }
            if (is_array($json)) {
                // batch results
                $results = [];
                $errors = [];

                foreach ($json as $result) {
                    if (property_exists($result,'result')) {
                        $results[] = $result->result;
                    } else {
                        if (isset($json->error)) {
                            $error = $json->error;
                            $errors[] = new RPCException(mb_ereg_replace('Error: ', '', $error->message), $error->code);
                        } else {
                            $results[] = null;
                        }
                    }
                }
                if (count($errors) > 0) {
                    call_user_func($callback, $errors, $results);
                } else {
                    call_user_func($callback, null, $results);
                }
            } elseif (property_exists($json,'result')) {
                call_user_func($callback, null, $json->result);
            } else {
                if (isset($json->error)) {
                    $error = $json->error;

                    call_user_func($callback, new RPCException(mb_ereg_replace('Error: ', '', $error->message), $error->code), null);
                } else {
                    call_user_func($callback, new RPCException('Something wrong happened.'), null);
                }
            }
        } catch (RequestException $err) {
            call_user_func($callback, $err, null);
        }
    }
1065354
protected void setPayload(String payload) {
        MessageContentBuilder messageContentBuilder = getMessageContentBuilder();

        if (messageContentBuilder instanceof PayloadTemplateMessageBuilder) {
            ((PayloadTemplateMessageBuilder) messageContentBuilder).setPayloadData(payload);
        } else if (messageContentBuilder instanceof StaticMessageContentBuilder) {
            ((StaticMessageContentBuilder) messageContentBuilder).getMessage().setPayload(payload);
        } else {
            throw new CitrusRuntimeException("Unable to set payload on message builder type: " + messageContentBuilder.getClass());
        }
    }
689850
public function get(string $url, ?array $payload = null): TransportClientResponse {
        return $this->sendRequest($url . static::QUESTION_MARK . http_build_query($payload), array());
    }
1282152
public static function receive($payload,$crypt=null){
		$stream = self::_get();
		if(!is_object($crypt))
			$stream->setCrypt(Crypt::_get(Config::get('xport','crypt.key'),Config::get('xport','crypt.iv')));
		else
			$stream->setCrypt($crypt);
		$stream->setup($payload);
		return $stream;
	}