@coroutine

@param int $code

@return \Generator

@resolve \Icicle\Http\Message\Response
4231
protected function createDefaultErrorResponse(int $code): \Generator
    {
        $sink = new MemorySink(sprintf('%d Error', $code));

        $headers = [
            'Connection' => 'close',
            'Content-Type' => 'text/plain',
            'Content-Length' => $sink->getLength(),
        ];

        return new BasicResponse($code, $headers, $sink);
        yield; // Unreachable, but makes method a coroutine.
    }
807596
public function runNow($code)
    {
        if (!Mage::getStoreConfig('system/cron/enableRunNow')) {
            Mage::throwException("'Run now' disabled by configuration (system/cron/enableRunNow)");
        }

        $schedule = Mage::getModel('cron/schedule')/* @var $schedule Aoe_Scheduler_Model_Schedule */
            ->setJobCode($code)
            ->setScheduledReason(Aoe_Scheduler_Model_Schedule::REASON_RUNNOW_API)
            ->runNow(false) // without trying to lock the job
            ->save();

        return $schedule->getData();
    }
305915
private function createErrorResponse(int $code, Socket $socket): \Generator
    {
        try {
            yield from $this->log->log(
                Log::NOTICE,
                'Error reading request from %s:%d (Status Code: %d)',
                $socket->getRemoteAddress(),
                $socket->getRemotePort(),
                $code
            );

            $response = $this->handler->onError($code, $socket);

            if ($response instanceof \Generator) {
                $response = yield from $response;
            } elseif ($response instanceof Awaitable) {
                $response = yield $response;
            }

            if (!$response instanceof Response) {
                throw new InvalidResultError(sprintf(
                    'A %s object was not returned from %::onError().',
                    Response::class,
                    get_class($this->handler)
                ), $response);
            }
        } catch (Throwable $exception) {
            yield from $this->log->log(
                Log::ERROR,
                "Uncaught exception when creating response to an error from %s:%d on %s:%d in file %s on line %d: %s",
                $socket->getRemoteAddress(),
                $socket->getRemotePort(),
                $socket->getLocalAddress(),
                $socket->getLocalPort(),
                $exception->getFile(),
                $exception->getLine(),
                $exception->getMessage()
            );
            $response = yield from $this->createDefaultErrorResponse(500);
        }

        return $response;
    }
316479
public function tokenize($code)
    {
        $this->tokens = array();
        $lines        = preg_split('/\r?\n/', $code);
        $number       = 0;

        foreach ($lines as $number => $fragment) {
            $this->processLine($number + 1, $fragment);
            $this->tokens[] = new Token(self::TOKEN_EOL, null, $number + 1);
        }
        $this->tokens[] = new Token(self::TOKEN_EOF, null, $number + 1);

        return new TokenStream($this->tokens);
    }
1203361
public function statusCode($code = null, $reasonPhrase = null)
    {
        if (func_num_args() < 1 || empty($code)) {
            return $this->response->getStatusCode();
        }
        $this->response = $this->response->withStatus($code, $reasonPhrase);
        return $this;
    }
680560
public function setHttpCode($code)
    {
        $this->addHeader(new Header\Header('HTTP/1.1 ' . (int) $code . ' ' . Header\HttpCode::getText($code), true, (int) $code));

        return $this;
    }
1164172
protected function jump($code = CodeConstant::CODE_SUCCESS, $msg = '', $url = '', $data = '', $wait = 3, $header = [])
    {
        $result = [
            'code' => $code,
            'msg' => $msg,
            'url' => $this->buildUrl($url),
            'data' => $data,
            'wait' => $wait
        ];
        if ($this->request->isAjax()) {
            Response::json($result, $header);
        } else {
            $template = $this->getJumpTemplate($code);
            $content = $this->fetch($template, $result);
            Response::data($content, 'html', 200, $header);
        }
    }
6575
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
    {
        $response = new Response('php://memory', $code, []);
        $response = $response->withStatus($code, $reasonPhrase);

        foreach ($this->config->baseHeaders() as $header => $value) {
            $response = $response->withAddedHeader($header, $value);
        }

        return $response;
    }
741260
public static function send_status($code) {
	if (!isset(static::$status_messages[$code])) {
		$code = self::STATUS_INTERNAL_SERVER_ERROR;
	}
	
	http_response_code($code);
}
247946
public function withStatus($code, $reasonPhrase = '') : self
    {
        $new = clone $this;

        return $new->setResponse(
            $this->response->withStatus($code, $reasonPhrase)
        );
    }
283901
public function code(int $code = 200) : Rest
  {
    $this->code = $code;
    header('HTTP/1.1 '.$this->code);
    return $this;
  }
932644
public function status( $code = null ) 
	{
		if ( !is_null( $code ) ) 
		{
			if ( headers_sent() && !CLI ) 
			{
				throw new CCException( "CCResponse::status - cannot change status header has already been send." );
			}

			$this->_status = $code; return $this;
		}

		return $this->_status;
	}
93061
public function setResponseCode(int $code)
    {
        if ($code < 100 || $code > 599)
        {
            $err = new \InvalidArgumentException("Attempting to set status code to $code");
            self::$logger->critical("Invalid status {0}: {1}", [$code, $err]);
            $this->response_code = 500;
        }
        else
        {
            $this->response_code = $code;
        }
        return $this;
    }
882836
public static function back(?int $code = null)
  {
    if (isset(getallheaders()['Referer'])) {
      return Redirect::to(getallheaders()['Referer'], $code);
    }

    return new Redirect('/');
  }
535897
public function code ( $code = NULL ) {
      if ( $code === NULL )
        return $this->code;
      if ( ResponseCode::find( $code ) === NULL )
        throw new \InvalidArgumentException( "Response: no code $code" );
      $this->code = intval( $code );
      return $this;
    }
506277
public function getResponse(int $code): Response
    {
        if (!isset($this->responses[$code])) {
            if (isset($this->responses[0])) {
                // Return default response
                return $this->responses[0];
            }
            throw new \InvalidArgumentException(
                "Operation '{$this->getId()}' does not have a definition for status '$code'" .
                " (has " . implode(', ', array_keys($this->responses)) . ')'
            );
        }

        return $this->responses[$code];
    }
208814
protected function getQueryHandlerConfiguration(string $code): QueryHandlerConfigurationInterface
    {
        if (!array_key_exists($code, $this->queryHandlerConfigurations)) {
            return $this->buildQueryHandlerConfiguration($code);
        }

        return $this->queryHandlerConfigurations[$code];
    }