Creates a response instance from an entire HTTP message including HTTP status headers and body.

@param  string $message The full HTTP message.
@param  string $options Additionnal options.
@return object          Returns a request instance.
5470
public static function parse($message, $options = [])
    {
        $parts = explode("\r\n\r\n", $message, 2);
        if (count($parts) < 2) {
            throw new NetException("The CRLFCRLF separator between headers and body is missing.");
        }
        $response = new static($options + ['format' => null]);

        list($header, $body) = $parts;

        $data = str_replace("\r", '', explode("\n", $header));
        $data = array_filter($data);

        preg_match('/HTTP\/(\d+\.\d+)\s+(\d+)(?:\s+(.*))?/i', array_shift($data), $matches);

        $headers = $response->headers();
        $headers->push($data);

        if ($matches) {
            $response->version($matches[1]);
            $response->status([$matches[2], isset($matches[3]) ? $matches[3] : '']);
        }

        if ($headers['Transfer-Encoding']->value() === 'chunked') {
            $decoded = '';
            while (!empty($body)) {
                $pos = strpos($body, "\r\n");
                $len = hexdec(substr($body, 0, $pos));
                $decoded .= substr($body, $pos + 2, $len);
                $body = substr($body, $pos + 2 + $len);
            }
            $body = $decoded;
        }

        $response->body($body);
        return $response;
    }
874033
protected function create404Response($message = null)
    {
        $response = $this->createResponse();
        $response->setStatusCode(404, $message);

        return $response;
    }
976103
public function create($body, $options = array()) {
        $options = new Values($options);

        $data = Values::of(array(
            'Body' => $body,
            'From' => $options['from'],
            'Attributes' => $options['attributes'],
        ));

        $payload = $this->version->create(
            'POST',
            $this->uri,
            array(),
            $data
        );

        return new MessageInstance(
            $this->version,
            $payload,
            $this->solution['serviceSid'],
            $this->solution['channelSid']
        );
    }
1319880
public function call(Message $message) : Message
    {
        $aggregate = $message->getHeaders()->containsKey(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_HEADER)
                            ? $message->getHeaders()->get(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_HEADER)
                            : null;
        $methodInvoker = MethodInvoker::createWith(
            $aggregate ? $aggregate : $message->getHeaders()->get(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_CLASS_NAME_HEADER),
            $message->getHeaders()->get(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_METHOD_HEADER),
            $this->messageToParameterConverters
        );

        $resultMessage = MessageBuilder::fromMessage($message);
        try {
            $result = $methodInvoker->processMessage($message);

            if (!$aggregate) {
                $resultMessage = $resultMessage
                    ->setHeader(CqrsMessagingModule::INTEGRATION_MESSAGING_CQRS_AGGREGATE_HEADER, $result);
            }
        } catch (\Throwable $e) {
            throw MessageHandlingException::fromOtherException($e, $message);
        }

        if (!is_null($result)) {
            $resultMessage = $resultMessage
                ->setPayload($result);
        }

        return $resultMessage
                ->build();
    }
714713
public function createRequest(PushMessage $message) : RequestInterface
    {
        $host = $message->getPushSubscription()->getEndpoint()->getHost();
        $pushService = $this->pushServiceRegistry->getPushService($host);

        return $pushService->createRequest($message);
    }
1303207
public function statusMessage($message = '')
    {
        $statusCode = $this->getStatusCode();

        if (!isset(ResponseHeader::$httpStatus[$statusCode])) {
            throw new ResponseException(sprintf('Invalid status code provided %s', $statusCode));
        }

        if (!empty($message)) {
            $this->statusMessage = $message;

            return $this;
        }

        $this->statusMessage = ResponseHeader::$httpStatus[$statusCode];

        return $this;
    }
930258
public static function DecryptMessage ($message, $key, $options = []) {
		$options = static::_AdjustOptions($options);
		return openssl_decrypt($message, $options['method'], $key, $options['openssl_options'], $options['iv']);
	}
1091173
public function write($message, $options = 0)
    {
        if ($message instanceof \Exception || (interface_exists('\Throwable') && $message instanceof \Throwable)) {
            echo $message;
            return $this;
        } elseif ($message instanceof \JsonSerializable) {
            echo json_encode($message, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
            return $this;
        } elseif ($message instanceof \Serializable) {
            echo serialize($message);
            return $this;
        } elseif (!is_array($message)) {
            echo (string)$message;
            return $this;
        }

        if (!isset($message[0]) || !is_string($message[0])) {
            echo json_encode($message, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
            return $this;
        }

        if (substr_count($message[0], '%') + 1 >= ($count = count($message)) && isset($message[$count - 1])) {
            foreach ((array)$message as $k => $v) {
                if ($k === 0 || is_scalar($v) || $v === null) {
                    continue;
                }

                if ($v instanceof \Exception || (interface_exists('\Throwable') && $v instanceof \Throwable)) {
                    $message[$k] = (string)$v;
                } elseif (is_array($v) || $v instanceof \JsonSerializable) {
                    $message[$k] = json_encode($v, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
                }
            }
            /** @noinspection ArgumentUnpackingCanBeUsedInspection */
            echo call_user_func_array('sprintf', $message);

            return $this;
        }

        if (count($message) === 2) {
            if (isset($message[1]) && strpos($message[0], ':1') === false) {
                if (is_scalar($message[1])) {
                    echo json_encode($message, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
                    return $this;
                } else {
                    $message[0] = rtrim($message[0], ': ') . ': :1';
                }
            }
        } elseif (count($message) === 3) {
            if (isset($message[1], $message[2]) && strpos($message[0], ':1') === false) {
                if (is_scalar($message[1]) && !is_scalar($message[2])) {
                    $message[0] = rtrim($message[0], ': ') . ': :1 => :2';
                } else {
                    echo json_encode($message, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
                    return $this;
                }
            }
        }

        if (strpos($message[0], ':') === false) {
            echo $this->colorize($message[0], $options);
        } else {
            $replaces = [];

            foreach ((array)$message as $k => $v) {
                if ($k === 0) {
                    continue;
                }

                if (is_int($v)) {
                    if (!$options && strpos($v, "\033[") === false) {
                        $v = $this->colorize($v, self::FC_GREEN);
                    }
                } elseif (is_string($v)) {
                    if (!$options && strpos($v, "\033[") === false) {
                        $v = $this->colorize($v, self::FC_CYAN);
                    }
                } elseif ($v instanceof \Exception || (interface_exists('\Throwable') && $v instanceof \Throwable)) {
                    $v = (string)$v;
                } elseif (is_array($v) || $v instanceof \JsonSerializable) {
                    $v = json_encode($v, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
                } elseif ($v instanceof \Serializable) {
                    $v = serialize($v);
                } elseif ($v === null || is_scalar($v)) {
                    $v = json_encode($v);
                } else {
                    $v = (string)$v;
                }

                $replaces[':' . $k] = $v;
            }

            echo $this->colorize(strtr($message[0], $replaces), $options);
        }

        return $this;
    }
528826
protected function buildResponse($data, $headers = [], $options = 0)
    {   
        $headers = array_merge($headers, $this->headers);

        $response = $data instanceof JsonResource
            ? $data->toResponse($this->request)
            : new JsonResponse($data, $this->getStatusCode(), $headers, $options);

        $response->setStatusCode($this->getStatusCode());

        return $response;
    }
1083625
public function handleMessage($message)
    {
        try {
            if ($message instanceof Invocation) {
                return $this->handleInvocation($message);
            }

            return $message;
        } catch (HomerException $e) {
            throw $e;
        } catch (Throwable $e) {
            Log::channel('homer')->warning($e->getMessage(), [
                'exception' => $e
            ]);

            throw $e;
        }
    }
519299
public function fromConsumedMessage(AMQPMessage $message)
    {
        return new Span(
            $this->getIdentifierOrGenerate($message, 'X-B3-SpanId'),
            $this->getMessageName($message),
            $this->getIdentifierOrGenerate($message, 'X-B3-TraceId'),
            [
                new Annotation(Annotation::SERVER_SEND, $this->clock->microseconds(), $this->endpointResolver->resolve()),
            ],
            [],
            $this->getIdentifier($message, 'X-B3-ParentSpanId'),
            $this->getMessageHeader($message, 'X-B3-Flags') == '1'
        );
    }
433381
protected function handleMessage($message)
    {
        if (!is_null($response = $this->call('message.*', array($message)))) {
            return $response;
        }

        return $this->call("message.{$message['MsgType']}", array($message));
    }
1077974
public function delivery(object $message, DeliveryOptions $options): Promise
    {
        $encoded = $this->encoder->handler->encode($message);

        $options->withHeader(Transport::SERVICE_BUS_SERIALIZER_HEADER, $this->encoder->tag);

        return $this->deferredDelivery(
            self::createPackage($encoded, $options, $this->destination)
        );
    }
656241
public function respondForbidden($message = null): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_FORBIDDEN)
            ->respondWithError(ApiResponse::CODE_FORBIDDEN, $message);
    }
364229
public function respondUpdated($message = "Updated")
    {
        $reponse = $this->setStatusCode(ResponseHTTP::HTTP_ACCEPTED)
            ->respondWithMessage($message);
        return $reponse;
    }
760282
public function request($message)
    {

        try {
            $body = $this->serializer->serialize($message);

            $data = $this->executeRequest($body);

            return $this->serializer->deserialize($data);
        } catch (HomerException $e) {
            $this->disconnect();

            throw $e;
        } catch (Throwable $e) {
            $this->disconnect();

            Log::channel('homer')->warning('Send rpc request failed', [
                'exception' => $e
            ]);

            throw new TransportException('Send rpc request failed, cause: '.$e->getMessage(), 0, $e);
        }
    }
611842
public function deserialize($data, Message $message, array $options = [])
    {
        $message = $this->messageSerializer->deserialize($data, $message, $options);

        if (isset($data['subject'])) {
            $subject = $this->om->getObject($data['subject'], Subject::class);

            if (!empty($subject)) {
                $message->setSubject($subject);
            }
        }

        if (isset($data['parent'])) {
            $parent = $this->om->getRepository($this->getClass())->findOneBy(['uuid' => $data['parent']['id']]);

            if ($parent) {
                $message->setParent($parent);
            }
        }
        $this->sipe('meta.flagged', 'setFlagged', $data, $message);
        $this->sipe('meta.moderation', 'setModerated', $data, $message);

        return $message;
    }