@param Envelope $envelope
@param Request  $request

@return bool
767505
private function isContentTypeOk(Envelope $envelope, Request $request): bool
    {
        if ($request->query->has('callback') && $request->isMethod('GET')) {
            // jsonp request, don't enforce
            $request->attributes->set('_jsonp_enabled', true);
            return true;
        }

        $request->attributes->set('_jsonp_enabled', false);
        $contentType = $request->headers->get('Content-Type');

        if (0 === strpos($contentType, 'multipart/form-data') || 0 === strpos($contentType, 'application/json')) {
            return true;
        }

        $envelope
            ->set('code', Code::INVALID_ARGUMENT)
            ->set('http_code', HttpCode::HTTP_NOT_ACCEPTABLE())
            ->set('error_name', 'NotAcceptable')
            ->set(
                'error_message',
                sprintf(
                    'This service supports [application/json] or [multipart/form-data], you provided [%s].',
                    $contentType
                )
            );

        return false;
    }
1331174
public function run(Request $request) {
		$page = $this->getServiceContainer()->getKernel()->getApplication()->getPage();
		$page->setTitle($this->getServiceContainer()->getTranslator()->trans('change_password'));

		$payload = new Blank();
		if ($request->isMethod('POST')) {
			$post = $request->request;
			$auth = $this->getServiceContainer()->getAuthManager();
			$user = $auth->getUser();
			$payload = new Failed();

			if ($post->has('password') && $auth->verifyUser($user, $post->get('password'))) {
				$pwA = $post->get('new_password');
				$pwB = $post->get('new_password_confirm');

				if ($pwA == $pwB) {
					$user->setPassword($auth->encryptPassword($pwA));
					$user->save();
					$payload = new Success();
				}
			}
		}

		return $this->responder->run($request, $payload);
	}
472248
private function validateEmail(Request $request)
    {
        $email = self::$validator->isString('email');

        $result = $email
            ->isRequired()
            ->isEmail()
            ->validate($request->email);

        $this->isValid = $this->isValid && $result;
        $this->errors  = array_merge($this->errors, $email->getErrors());
    }
657091
public function setRequest(Request $request)
    {
        $this->issuer->setRequest($request);
        $this->checker->setRequest($request);
    }
321761
protected function handleProcessFlag(Envelope $envelope, DeliveryResult $flag)
    {
        $this->countMessagesConsumed++;

        switch ($flag) {
            case DeliveryResult::MSG_REJECT():
                $this->queue->nack($envelope->getDeliveryTag(), Constants::AMQP_NOPARAM);
                $this->logger->debug('Rejected message', $this->extractMessageInformation($envelope));
                break;
            case DeliveryResult::MSG_REJECT_REQUEUE():
                $this->queue->nack($envelope->getDeliveryTag(), Constants::AMQP_REQUEUE);
                $this->logger->debug('Rejected and requeued message', $this->extractMessageInformation($envelope));
                break;
            case DeliveryResult::MSG_ACK():
                $this->countMessagesUnacked++;
                $this->lastDeliveryTag = $envelope->getDeliveryTag();
                $this->timestampLastMessage = microtime(true);
                $this->ack();
                break;
            case DeliveryResult::MSG_DEFER():
                $this->countMessagesUnacked++;
                $this->lastDeliveryTag = $envelope->getDeliveryTag();
                $this->timestampLastMessage = microtime(true);
                break;
        }
    }
494001
protected function consumeCallback(Message $message, Envelope $envelope = null) : bool
    {
        if ($message->getMessage()) {
            $this->count++;
        }

        if ($message->getMessage()) {
            return $this->consume($message, $envelope);
        }

        if ($this->mustQuit()) {
            $message->quit(true);
        }

        return true;
    }
163204
public static function useHttps(Request $request): bool
    {
        $checks = [
            'HTTPS',
            'SERVER_PORT',
            'HTTP_X_FORWARDED_SSL',
            'HTTP_X_FORWARDED_PROTO',
        ];
        foreach ($checks as $check) {
            if (call_user_func([__CLASS__, sprintf('check%s', Text::toCamelCase($check))], $request)) {
                return true;
            }
        }

        return false;
    }
947842
private void processEnvelope(Envelope envelope) {

        ActorScope scope = envelope.getScope();

        if (actorSystem.getTraceInterface() != null) {
            actorSystem.getTraceInterface().onEnvelopeDelivered(envelope);
        }

        long start = ActorTime.currentTime();
        if (scope.getActor() == null) {

            if (envelope.getMessage() == PoisonPill.INSTANCE) {
                // Not creating actor for PoisonPill
                return;
            }

            try {
                Actor actor = scope.getProps().create();
                actor.initActor(scope.getPath(), new ActorContext(scope), scope.getMailbox());
                ThreadDispatcher.pushDispatcher(actor.getDispatcher());
                try {
                    actor.preStart();
                } finally {
                    ThreadDispatcher.popDispatcher();
                }

                scope.onActorCreated(actor);
            } catch (Exception e) {
                e.printStackTrace();
                if (envelope.getSender() != null) {
                    envelope.getSender().send(new DeadLetter("Unable to create actor"));
                }
                return;
            }
        }

        try {
            if (envelope.getMessage() == StartActor.INSTANCE) {
                // Already created actor
            } else if (envelope.getMessage() == PoisonPill.INSTANCE) {
                ThreadDispatcher.pushDispatcher(scope.getActor().getDispatcher());
                try {
                    scope.getActor().postStop();
                } finally {
                    ThreadDispatcher.popDispatcher();
                }
                onActorDie(scope);
            } else {
                scope.getActor().handleMessage(envelope.getMessage(), envelope.getSender());
            }
        } catch (Exception e) {
            if (actorSystem.getTraceInterface() != null) {
                actorSystem.getTraceInterface().onActorDie(scope.getActorRef(), envelope, e);
            }
            ThreadDispatcher.pushDispatcher(scope.getActor().getDispatcher());
            try {
                scope.getActor().postStop();
            } finally {
                ThreadDispatcher.popDispatcher();
            }
            onActorDie(scope);
        } finally {
            if (actorSystem.getTraceInterface() != null) {
                actorSystem.getTraceInterface().onEnvelopeProcessed(envelope, ActorTime.currentTime() - start);
            }
        }
    }
954699
public function accept(Request $request)
    {
        if (! $request->has('token')) abort(404);
        if (! $invitation = $this->validateToken($request->input('token'))) abort(404);
        return $this->showAcceptUserInvitationForm($invitation);
    }
1156465
public function matches(Route $route, Request $request)
    {
        if (call_user_func_array($route->getCondition(), $route->getConditionParameters())) {
            return true;
        }

        return false;
    }
572872
function envelope(service_name){

    var anchor = this;

    anchor._is_a = 'bbop-service-envelope';

    // Start the timer.
    anchor._start_time = second_count();

    // Theoretical good result frame.
    anchor._envelope = {
	service: 'n/a',
	status: 'success',
	arguments: {},
	comments: [],
	data: {}
    };

    //
    if( service_name && typeof(service_name) === 'string' ){
	anchor._envelope['service'] = service_name;
    }
}
1295037
protected function sendReply(Response $response, Envelope $envelope)
    {
        $attributes = [
            'content_type' => 'application/json',
            'content_encoding' => 'UTF-8',
            'delivery_mode' => 2,
            'correlation_id' => $envelope->getCorrelationId(),
            'app_id' => $this->appId,
            'headers' => [
                'jsonrpc' => JsonRpcResponse::JSONRPC_VERSION,
            ],
        ];

        if ($response->isError()) {
            $payload = [
                'error' => [
                    'code' => $response->error()->code(),
                    'message' => $response->error()->message(),
                ],
                'data' => $response->data(),
            ];
        } else {
            $payload = [
                'result' => $response->result(),
            ];
        }

        $message = json_encode($payload);

        if (json_last_error() !== JSON_ERROR_NONE) {
            $message = json_encode([
                'error' => [
                    'code' => JsonRpcError::ERROR_CODE_32603,
                    'message' => 'Internal error',
                ],
            ]);
        }

        $this->exchange->publish($message, $envelope->getReplyTo(), Constants::AMQP_NOPARAM, $attributes);
    }
861091
public function send(Request $request)
    {
        $response   = new GetSchemaResponse();
        $rpbGetReq  = $this->createRpbMessage($request);
        $rpbGetResp = $this->client->send($rpbGetReq, RiakMessageCodes::YOKOZUNA_SCHEMA_GET_REQ, RiakMessageCodes::YOKOZUNA_SCHEMA_GET_RESP);

        if ( ! $rpbGetResp instanceof RpbYokozunaSchemaGetResp) {
            return $response;
        }

        if ( ! $rpbGetResp->hasSchema()) {
            return $response;
        }

        $response->name    = $rpbGetResp->schema->name;
        $response->content = $rpbGetResp->schema->content;

        return $response;
    }
1114781
public function isValid(Request $request)
    {
        $arguments = $this->method === "GET" ? $request->get : $request->post;
        $files = $request->files;

        if (!$this->validate($arguments, $files))
            return false;

        $params = ['form' => $this, 'request' => $request, 'valid' => true, 'arguments' => $arguments];
        $params = TypedDictionary::wrap($params);
        $params->setType('errors', Type::ARRAY);
        $result = Hook::execute('Wedeto.HTTP.Forms.Form.isValid', $params);

        if (!$result['valid'])
        {
            foreach ($result['errors'] as $field => $errors)
            {
                if ($errors instanceof Dictionary)
                    $this->errors[$field] = $errors->toArray();
            }
            return false;
        }

        unset($this->form_elements[Nonce::getParameterName()]);
        unset($this->form_elements['_form_name']);

        return true;
    }
392923
public boolean processMultipleReply(MessageEnvelope envelope) {
		if (this.event == null) {
			return false;
		}
		boolean triggered = this.event.verifyEventCondition(envelope);
		if (triggered) {
			beforeReply(envelope);
			if (this.replies != null) {
				synchronized (replies) {
					for (AutoReply reply : replies) {
						reply.reply(envelope);
					}
				}
			}
			afterReply(envelope);
		}
		return triggered;
	}
1322901
public final boolean verifyEventCondition(MessageEnvelope envelope) {
		String message = safeGetQuickReplyPayload(envelope);
		return expectedPattern.matcher(message).matches();
	}
639786
protected function storeMessageEnvelope(MessageEnvelope $envelope)
	{
		// Add the given anvelope to the messages array
		$this->messageEnvelopeStore[self::MESSAGE_ENVELOPE_STORE_PREFIX . $envelope->getIdentifier()] = $envelope;
	}