processes SOAP message received from client

@param array  $headers The HTTP headers
@param string $data    unprocessed request data from client

@return    mixed    value of the message, decoded into a PHP type
@access   private
357818
function parseRequest($headers, $data)
    {
        $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
        $this->requestAttachments = [];
        if (strstr($headers['content-type'], 'multipart/related')) {
            $this->debug('Decode multipart/related');
            $input = '';
            foreach ($headers as $k => $v) {
                $input .= "$k: $v\r\n";
            }
            $params['input']          = $input . "\r\n" . $data;
            $params['include_bodies'] = TRUE;
            $params['decode_bodies']  = TRUE;
            $params['decode_headers'] = TRUE;

            $structure = Mail_mimeDecode::decode($params);

            foreach ($structure->parts as $part) {
                if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
                    $this->debug('Have root part of type ' . $part->headers['content-type']);
                    $return = parent::parseRequest($part->headers, $part->body);
                } else {
                    $this->debug('Have an attachment of type ' . $part->headers['content-type']);
                    $info['data']               = $part->body;
                    $info['filename']           = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
                    $info['contenttype']        = $part->headers['content-type'];
                    $info['cid']                = $part->headers['content-id'];
                    $this->requestAttachments[] = $info;
                }
            }

            if (isset($return)) {
                return $return;
            }

            $this->setError('No root part found in multipart/related content');

            return;
        }
        $this->debug('Not multipart/related');

        return parent::parseRequest($headers, $data);
    }
628923
public function handleData($data)
    {
        $this->incomingBuffer .= $data;

        if ($this->connection && $this->isHeaderEnd($this->incomingBuffer)) {
            $remoteAddress = (string) $this->incoming->getRemoteAddress();
            $headersToReplace = [
                'X-PHP-PM-Remote-IP' => trim(parse_url($remoteAddress, PHP_URL_HOST), '[]'),
                'X-PHP-PM-Remote-Port' => trim(parse_url($remoteAddress, PHP_URL_PORT), '[]')
            ];

            $buffer = $this->replaceHeader($this->incomingBuffer, $headersToReplace);
            $this->connection->write($buffer);

            $this->incoming->removeListener('data', [$this, 'handleData']);
            $this->incoming->pipe($this->connection);
        }
    }
1198947
function parse($data)
    {
        $_header = strstr($data, self::HTTP_EOF, true);
        if ($_header === false)
        {
            $this->buffer = $data;
        }
        $header = self::parseHeader($_header);
        if ($header === false)
        {
            $this->isError = true;
        }
        $this->header = $header;
        return $header;
    }
572009
public function deferredRevenue(array $data = [], array $headers = [])
    {
        $url = $this->url('exports/deferred_revenue');

        return $this->post($url, $data, $headers);
    }
797156
public function send($data = null, array $headers = [])
    {
        $response = [
            'status'  => $statusCode = $this->statusCode,
            'reason'  => $reasonPhrase = readable($this->reasonPhrase),
            'success' => true,
            'message' => null,
            'result'  => [],
        ];

        if (is_array($data)) {
            if (isset($data[ 'status' ])) {
                $response[ 'status' ] = $statusCode = $data[ 'status' ];
                unset($data[ 'status' ]);
            }

            if (isset($data[ 'reason' ])) {
                $response[ 'reason' ] = $reasonPhrase = $data[ 'reason' ];
                unset($data[ 'reason' ]);
            }

            if (isset($data[ 'success' ])) {
                $response[ 'success' ] = $data[ 'success' ];
                unset($data[ 'success' ]);
            }

            if (isset($data[ 'message' ])) {
                $response[ 'message' ] = $data[ 'message' ];
                unset($data[ 'message' ]);
            }

            if (isset($data[ 'metadata' ])) {
                $response[ 'metadata' ] = $data[ 'metadata' ];
                unset($data[ 'metadata' ]);
            }

            if (isset($data[ 'result' ])) {
                $data = $data[ 'result' ];
            }

            if (isset($data[ 'data' ])) {
                $data = $data[ 'data' ];
            }
        } elseif (is_object($data)) {
            if (isset($data->status)) {
                $response[ 'status' ] = $statusCode = $data->status;
                unset($data->status);
            }

            if (isset($data->reason)) {
                $response[ 'reason' ] = $reasonPhrase = $data->reason;
                unset($data->reason);
            }

            if (isset($data->success)) {
                $response[ 'success' ] = $data->success;
                unset($data->success);
            }

            if (isset($data->message)) {
                $response[ 'message' ] = $data->message;
                unset($data->message);
            }

            if (isset($data->result)) {
                $data = $data->result;
            }

            if (isset($data->data)) {
                $data = $data->data;
            }
        }

        if (is_object($data) and method_exists($data, 'getArrayCopy')) {
            $data = $data->getArrayCopy();
        }

        $this->sendHeaderStatus($statusCode, $reasonPhrase);

        $this->sendHeaders($headers);

        if (is_object($data) and method_exists($data, 'getArrayCopy')) {
            $data = $data->getArrayCopy();
        }

        if (is_array($data)) {
            if (is_string(key($data))) {
                $response[ 'result' ] = [$data];
            } elseif (is_numeric(key($data))) {
                $response[ 'result' ] = $data;
            }
        } else {
            $response[ 'result' ] = $data;
        }

        if (is_ajax()) {
            $contentType = isset($_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ]) ? $_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ] : 'application/json';
            $this->setContentType($contentType);
        }

        if ($this->mimeType === 'application/json') {
            echo json_encode($response, JSON_PRETTY_PRINT);
        } elseif ($this->mimeType === 'application/xml') {
            $xml = new \SimpleXMLElement('<?xml version="1.0"?><response></response>');
            $xml->addAttribute('status', $statusCode);
            $xml->addAttribute('reason', $reasonPhrase);
            $this->arrayToXml($response, $xml);

            echo $xml->asXML();
        } elseif(is_cli()) {
            print_cli($response, true);
        } elseif(is_array($response['result'])) {
            print_r($response['result']);
        } else {
            echo $response[ 'result' ];
        }
    }
1020588
public function set(array $data, array $headers = [])
    {
        $url = $this->url('promotional_credits/set');

        return $this->post($url, $data, $headers);
    }
278323
public function add(array $data, array $headers = [])
    {
        $url = $this->url('promotional_credits/add');

        return $this->post($url, $data, $headers);
    }
982358
private function extractEncoderKey(array $headers): string
    {
        /** @var string $encoderKey */
        $encoderKey = $headers[Transport::SERVICE_BUS_SERIALIZER_HEADER] ?? self::DEFAULT_DECODER;

        return $encoderKey;
    }
114498
public function save(array $headers, array $data)
    {
        $output = $contents = [];

        $enclosure = $this->getCsvEnclosure();
        $delimiter = $this->getCsvDelimiter();

        $contents[] = $enclosure
            . implode($enclosure . $delimiter . $enclosure, $headers)
            . $enclosure;

        if (!empty($data)) {
            foreach ($data as $item) {
                foreach ($item as $line) {
                    foreach ($headers as $index => $value) {
                        if (isset($line[$value]) && $line[$value] !== '') {
                            $output[$value] = $enclosure . (string)$line[$value] . $enclosure;
                            unset($line[$value]);
                        } else {
                            $output[$value] = '';
                        }
                    }
                    $contents[] = implode($delimiter, array_merge($output, $line));
                }
            }
        }

        $filePath = $this->getFilePath();

        if (file_put_contents($filePath, chr(239) . chr(187) . chr(191) . implode("\n", $contents))) {
            return $filePath;
        }

        return '';
    }
1021684
public function _flush($data)
    {
        if ($this->_cancel) {
            return $data;
        }
        $contentType = null;
        $storedHeaders = array();
        $headersList = headers_list();
        foreach($this->_specificOptions['memorize_headers'] as $key=>$headerName) {
            foreach ($headersList as $headerSent) {
                $tmp = explode(':', $headerSent);
                $headerSentName = trim(array_shift($tmp));
                if (strtolower($headerName) == strtolower($headerSentName)) {
                    $headerSentValue = trim(implode(':', $tmp));
                    $storedHeaders[] = array($headerSentName, $headerSentValue);
                }
            }
        }
        $array = array(
            'data' => $data,
            'headers' => $storedHeaders
        );
        $this->save($array, null, $this->_activeOptions['tags'], $this->_activeOptions['specific_lifetime'], $this->_activeOptions['priority']);
        return $data;
    }
443280
public function post($service, $headers = null, $data = null)
	{
		return $this->customRequest($service, 'POST', $headers, $data);
	}
1055599
public function rawRequest(array $data = [], array $headers = []) {
        foreach ($headers as $header => $value) {
            $this->options[CURLOPT_HTTPHEADER][] = $header . ': ' . $value;
        }

        return $this->execute($data);
    }
276997
public function update(array $data, array $headers = [])
    {
        $url = $this->url('addresses');

        return $this->post($url, $data, $headers);
    }
860650
public function put($service, $headers = null, $data = null)
	{
		return $this->customRequest($service, 'PUT', $headers, $data);
	}
109238
public function doAction($methodName, $payload, $httpHeaders)
    {
        $this->setHttpHeader($httpHeaders);
        self::$soapClient->__setSoapHeaders($this->getAuthHeader());
        $response = self::$soapClient->$methodName($payload);

        return json_encode($response);
    }
51359
public function xssClean(array $data)
    {
        foreach ($data as $k => $v) {
            $data[$k] = filter_var($v, FILTER_SANITIZE_STRING);
        }

        return $data;
    }
1006409
protected function request($url, $data, $headers=array())
    {
        try{
            $result = $this->validate($url, $data);
            if($result !== true) {
                return $result;
            }

            $params = array();
            // 特殊处理
            $this->proccessRequest($url, $params, $data, $headers);
            if($this->methods == 'get') {
                $response = $this->client->get($url, $data);
            } else {
                $response = $this->client->post($url, $data, $params);
            }
            $obj = $this->proccessResult($response['content']);
        }catch(Exception $e){
            return array(
                'error_code' => 'SDK108',
                'error_msg' => 'connection or read data timeout',
            );
        }
        return $obj;
    }