Writes data to server and checks response against expected code if some provided.
@param  int|int[] $expectedCode
542658
protected function write($line, $expectedCode = null, $message = null)
    {
        fwrite($this->_connection, $line . "\r\n");
        if (!$expectedCode) {
            return;
        }
        $response = $this->read();
        if (!in_array((int) $response, (array) $expectedCode, true)) {
            throw new NetException('SMTP server did not accept ' . ($message ? $message : $line) . ' with error: ' . trim($response));
        }
    }
488003
protected function updateCurrency($code)
    {
        if (!$this->isError() && !$this->currency->update($code, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
618900
private function considerStatusCodes(array $statusCodes): void
    {
        $this->requestCount += count($statusCodes);

        if ($this->autoShutdown) {
            foreach ($statusCodes as $statusCode) {
                if ($statusCode >= 500 && $statusCode < 600) {
                    $this->flagShutdown('Automatic shutdown following status code: ' . $statusCode);
                    break;
                }
            }
        }
    }
482487
public function setExitCode($exitCode)
    {
        $this->exitCode = (int) $exitCode;

        $r = new \ReflectionProperty($this->error, 'code');
        $r->setAccessible(true);
        $r->setValue($this->error, $this->exitCode);
    }
498877
protected function generateHttpError($errorCode = 404) {

		$content =
				'<h1>' .
				$errorCode .
				' ' .
				Response::$statusTexts[$errorCode] .
				'</h1>';

		Response::create($content, $errorCode)->send();
		exit();

	}
487937
public static function create(
        $expected,
        $actual,
        $paramNo = null,
        $code = null,
        $previous = null
    ) {
        $msgMsk = 'Expected %1$s. Got %2$s';

        if ($paramNo !== null) {
            $msgMsk = 'Param #%3$s '.lcfirst($msgMsk);
        }

        if ($code !== null) {
            $msgMsk = '[%4$s] '.$msgMsk;
        }

        $class = get_called_class();
        return new $class(
            sprintf(
                $msgMsk,
                $expected,
                Debug::summarise($actual),
                $paramNo,
                $code
            ),
            is_int($code) ? $code : null,
            $previous
        );
    }
582417
protected function write(array $record): void
    {
        $this->ensureProcessIsStarted();

        $this->writeProcessInput($record['formatted']);

        $errors = $this->readProcessErrors();
        if (empty($errors) === false) {
            throw new \UnexpectedValueException(sprintf('Errors while writing to process: %s', $errors));
        }
    }
927704
protected function error($code)
    {
        $this->sendFrame('c' . json_encode([$code, isset($this->errors[$code]) ? $this->errors[$code] : null]));
    }
844068
private function setStatusHeader($code = 200)
    {
        if (empty(self::$codes[$code])) {
            $code = 200;
        }

        if (!empty($this->response)) {
            $this->response->status($code);
        }

        return $this;
    }
1156530
public function onBeforeHTTPError($code, $request)
    {

        $errorPage = ErrorPage::get()->filter(array(
                'ErrorCode' => $code,
                'SiteID' => Multisites::inst()->getCurrentSiteId()
            ))->first();
        if ($errorPage) {
            Requirements::clear();
            Requirements::clear_combined_files();
            $response = ModelAsController::controller_for($errorPage)->handleRequest($request);
            throw new HTTPResponse_Exception($response, $code);
        }
    }
703163
public function respond(int $statusCode = null, array $headers = []):JsonResponse
    {
        if (! is_null($statusCode)) {
            $this->setStatus($statusCode);
        }

        $data = $this->toArray();
        $data = $this->includeStatusCode($data);
        $data = $this->includeSuccessFlag($data);

        return $this->responseFactory->json($data, $this->statusCode, $headers);
    }
322433
public function setCode( $code )
	{
		$this->_checkCode( $code );

		$this->_values['code'] = (string) $code;
		$this->setModified();
	}
187154
public function assertResponseCodeIs($code) {
        $this->requireResponse();

        try {
            Assertion::same(
                $actual = $this->response->getStatusCode(),
                $expected = $this->validateResponseCode($code),
                sprintf('Expected response code %d, got %d.', $expected, $actual)
            );
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
8847
public function setStatusCode($code = null)
    {
        if (!empty($code)) {
            $this->_statusCode = $code;
            http_response_code($this->_statusCode); // this sends the http status code
        }
    }
777583
public function assertSourceMissing($code)
    {
        PHPUnit::assertFalse(
            Str::contains($this->driver->getPageSource(), $code),
            "Found unexpected source code [{$code}]"
        );

        return $this;
    }
1301542
public function preOutputNoLineFeed($code)
    {
        $this->lastLine = $code;
        $this->code = str_repeat("\t", $this->level).$code.$this->code;
    }
1303782
protected function response($data,$type='',$code=200) {
        $this->sendHttpStatus($code);
        exit($this->encodeData($data,strtolower($type)));
    }