Set a response.

@param string $type
@param any    $response the "$response" is framework interface or array.

@author Seven Du <shiweidu@outlook.com>
195081
public function setResponse(string $type, $response)
    {
        $this->response = new Response($type, $response);
        $this->initialized['response'] = true;

        return $this;
    }
999139
public function setSubject($subject)
    {
        if (!is_string($subject)) {
            throw new TypeException('$subject must be of type string.');
        }
        if (!($subject instanceof Subject)) {
            $this->subject = new Subject($subject);
        } else {
            $this->subject = $subject;
        }
    }
1320686
protected function setNeededAction(Response $response) {
        if ($response->hasHtml())
        {
            $response->setNeededAction(Response::NEEDED_SHOW_HTML);
        }
        elseif ($response->isProcessing())
        {
            $response->setNeededAction(Response::NEEDED_STATUS_UPDATE);
        }
    }
61316
public function prepareForResponse(Response $response) {
		$response->setHeader('Content-Type: ' . $this->getContentType());

		if (!$this->isInitialized()) {
			$this->initialize();
		}
	}
1103548
public function setType($type)
    {
        switch ($type) {
            case self::TYPE_CSV:
                $this->headers->add(array('Content-Type' => 'text/csv;charset=' . self::UTF_16_LE));
                break;
            case self::TYPE_XLS:
                $this->headers->add(array("Content-Type" => "application/vnd.ms-excel"));
                break;
        }
        $this->type = $type;
    }
387935
public function setResponse(iterable $response): ResponseSelector
    {
        if (!$response instanceof Collection) {
            $response = new Collection($response);
        }

        $this->response = $response;

        return $this;
    }
297663
public function setType($type)
    {
        if ($type === null) {
            $type = self::TYPE_UNDEFINED;
        }

        $this->type = $type;

        return $this;
    }
598496
public function setRequest(string $type, $request)
    {
        $this->request = new Request($type, $request);
        $this->initialized['request'] = true;

        return $this;
    }
380317
public static function setResponse(ResponseInterface $response)
    {
        $coroutineId = self::getCoroutineId();
        self::$context[$coroutineId][self::RESPONSE_KEY] = $response;
    }
473363
public function setType($type)
    {
        if ($type instanceof Type) {
            $this->setIndex($type->getIndex());
            $type = $type->getName();
        }

        return $this->setParam('_type', $type);
    }
629320
public function setBaseResponse(ResponseInterface $response)
    {
        if ($response instanceof GlobalEnvironmentInterface && $response->isStale()) {
            throw new \RuntimeException("Unable to set base response: Response is stale");
        }
        
        $this->baseResponse = $response;
    }
1190760
public function set($message, $type = 'success') {
        $key = self::BANDAMA_FLASH_KEY.'_'.$type;
        $this->session->set($key, $message);
    }
5513
protected function setResponseData(Response $response, array $data)
    {
        if ($response instanceof JsonResponse) {
            /** @var $response JsonResponse */
            return $response->setData($data);
        }

        $content = json_encode($data, JsonResponse::DEFAULT_ENCODING_OPTIONS);

        return $response->setContent($content);
    }
1374452
public function setType($type)
    {
        $const = sprintf('%s::TYPE_%s', __CLASS__, strtoupper($type));
        
        if(defined($const))
        {
            $type = constant($const);
        }
        
        $this->setAttributeDirectly('type', $type);
        
        $this->enumerationStrategy = null;
    }
67904
public function setResponse(Response $response): void
    {
        if ($this->hasResponse()) {
            throw new LogicException('Response can only be set one time.');
        }

        if (!$response->has('ctx_request')) {
            $response->set('ctx_request', $this->message);
        }

        if (!$response->has('ctx_request_ref')) {
            $response->set('ctx_request_ref', $this->message->generateMessageRef());
        }

        if (!$response->has('ctx_correlator_ref') && $this->message->has('ctx_correlator_ref')) {
            $response->set('ctx_correlator_ref', $this->message->get('ctx_correlator_ref'));
        }

        $this->response = $response;
        $this->stopPropagation();
    }
279143
public function setPostType($type)
    {
        if (!in_array($type, [0, 1, 2, 3, 4, 5])) {
            $this->postType = self::POST_FORM_DATA;
        } else {
            $this->postType = $type;
        }
        return $this;
    }
212017
public function respond($response)
	{
		if (
			$this->logger !== null &&
			$this->logger->isHandling(Logger::DEBUG)
		) {
			$this->logger->addDebug(
				'Send response',
				array(
					 'content-type' => $this->contentType,
					 'response'     => ctype_print($response) ? $response : 'base64:' . base64_encode($response)
				)
			);
		}

		ob_start();
		while (ob_end_clean()) {
		}
		header('Content-Type: ' . $this->contentType);
		echo $response;
	}