Set the response content type header and status code.

@param string $type Response content type.
@param int $statusCode Response status code.
352888
public function setContentType($type, $statusCode=null)
    {
        if (isset(static::$_types[$type])) {
            $type = static::$_types[$type];
        }
        $this->setHeader('Content-Type', $type);
        if ($statusCode) {
            $this->_statusCode = $statusCode;
        }
    }
113216
protected function generateResponse($statusCode, $json)
    {
        if (empty($json) && $statusCode == Response::REST_SUCCESS_NO_CONTENT) {
            return new Response(array(), $statusCode);
        } else {
            $body = json_decode($json, true);
            if ($body == null) {
                throw new ClientException('Error while sending request to api; Received invalid json: ' . $json, ClientException::SERVER_UNAVAILABLE);
            }
            $response = new Response($body, $statusCode);
            $this->validateServerResponse($response);

            return $response;
        }
    }
594986
public void setContentType(String type) {
		checkContentType(type);
		checkCommitted();
		String name = getCorrectHeaderName(ContentTypeHeader.NAME);
		try {
			Header h = SipFactoryImpl.headerFactory.createHeader(name, type);
			this.message
					.removeHeader(getCorrectHeaderName(ContentTypeHeader.NAME));
			this.message.addHeader(h);
		} catch (ParseException e) {
			logger.error("Error while setting content type header !!!", e);
		}

	}
1281056
public function setStatusCode(int $statusCode): void {
		if ($this->compiled) {
			throw new ResponseException("Attempt to alter response after compilation.", ResponseException::AFTER_COMPILE_ALTERATION);
		}
		
		if (!in_array($statusCode, array_keys($this->phrases))) {
			throw new ResponseException("Unknown status code: $statusCode.");
		}
		
		$this->statusCode = $statusCode;
	}
1210336
protected function setRequestType(string $type):void
    {
        if ($type !== Protocol::REQUEST_TYPE_NOTIFY && $type !== Protocol::REQUEST_TYPE_FORWARD && $type !== protocol::REQUEST_TYPE_REGISTER) {
            throw new \TypeError("Unsupported request type: $type!");
        }

        $this->requestType = $type;
        $this->setHeader(Protocol::VERSION." ".$type);

    }
859686
public function setStatusCode($statusCode)
    {
        $statusCode = (int)$statusCode;
        if ($statusCode < 100 || $statusCode >= 600) {
            throw new \Exception("Invalid status code: {$statusCode}.");
        }
        $this->statusCode = $statusCode;
        return $this;
    }
1176861
public function response($statusCode = null)
        {
            $response = $this->factory(__NAMESPACE__ . '\Response');

            if (is_numeric($statusCode)) {
                $response->status($statusCode);
            }

            return $response;
        }
1360765
public function setStatusCode($statusCode)
    {
        $statusCode = intval($statusCode);
        $this->statusCode = ($statusCode > 0) ? $statusCode : self::RESPONSE_OK;
        return $this;
    }
400557
protected function setResponseError($error, int $statusCode = 500) : void
    {
        if ($error instanceof \Exception) {
            $error = $error->getMessage();
        }

        $this->response['message'] = (string)$error;
        $this->response['status'] = $statusCode;
    }
1071650
protected function createResponse($content = '', $statusCode = 200, $contentType = 'application/json')
    {
        if ('' === $content && 'application/json' === $contentType) {
            $content = '{}';
        }

        $response = new Response($content, $statusCode);
        $response->headers->set('Content-Type', $contentType);

        return $response;
    }
92392
public static function setResponseStatus(int $status) : void
    {
        if (array_key_exists($status, Http::$http_status_messages)) {
            header('HTTP/1.1 ' . $status . ' ' . Http::$http_status_messages[$status]);
        }
    }
1299729
public function setStatusCode($statusCode, $text = null)
    {
        // Fallback status code message if missing
        if (! empty($text)) {
            $statusText = $text;
        } elseif (! empty(self::$statusTexts[$statusCode])) {
            $statusText = self::$statusTexts[$statusCode];
        } else {
            $statusText = 'Undefined code';
        }

        // Set status code and text
        $this->statusCode = $statusCode;
        $this->statusText = $statusText;

        // Validate status code
        if ($this->isInvalid()) {
            throw new InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $statusCode));
        }

        return $this;
    }
405317
public function respond(Status $status, $content = '')
    {
        $this->header($status);

        if (!empty($content)) {
            $this->send($content);
        }

        return $this;
    }
340755
public function thenRespond($statusCode, $body)
    {
        $response = HttpResponseBuilder::create($statusCode)
            ->andBody(new Body($body))
            ->build();

        return $this->createMockConfig($response);
    }
808916
protected function makeHtmlResponse($statusCode)
    {
        $view = $this->getView();

        if ($statusCode !== SymfonyResponse::HTTP_OK) {
            $view->withErrors($this->getErrorBagForStatusCode($statusCode));
        }

        return new IlluminateHtmlResponse($view, $statusCode);
    }
326968
protected function response($data, $code = 200, $type = "json")
    {
        $this->http_status($code);
        Util::rep_send($data, $type);
    }
952985
public static function SetStatus(int $status, bool $exit = false) :void
        {
            if (!HttpStatusCode::IsSupported($status)) {
                throw new \Error("Status code {$status} is not supported");
            }

            self::$status = $status;
            self::AddHeader('Status', $status);

            if ($exit) {
                self::ApplyHeaders();
                exit();
            }
        }