Set the status code of the response message.

@param code
494574
@Override
    public void setStatusCode(StatusCodes code) {

        if (!code.equals(this.myStatusCode)) {
            this.myStatusCode = code;
            // no matter what, empty out the reason phrase information so that it
            // will default to match this new status code
            this.myReason = null;
            this.myReasonBytes = null;
            super.setFirstLineChanged();
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "setStatusCode(sc): " + code);
        }
    }
112122
public static ResponseStatus valueOf(int code) {
    code = code & 0xFFFF; // convert negative shorts to unsigned
    if (code < 256) {
      ResponseStatus status = values[code];
      if (status != null) {
        return status;
      }
    }
    return new ResponseStatus(code);
  }
1275787
public static SpdySessionStatus valueOf(int code) {
        switch (code) {
        case 0:
            return OK;
        case 1:
            return PROTOCOL_ERROR;
        case 2:
            return INTERNAL_ERROR;
        }

        return new SpdySessionStatus(code, "UNKNOWN (" + code + ')');
    }
747861
private function setStatusCode($code, $reasonPhrase = ''): void
    {
        if (
            !\is_numeric($code) || \is_float($code) ||
            $code < static::MIN_STATUS_CODE_VALUE ||
            $code > static::MAX_STATUS_CODE_VALUE
        ) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid status code "%s"; must be an integer between %d and %d, inclusive',
                \is_scalar($code) ? $code : \gettype($code),
                static::MIN_STATUS_CODE_VALUE,
                static::MAX_STATUS_CODE_VALUE
            ));
        }

        if (!\is_string($reasonPhrase)) {
            throw new \InvalidArgumentException(\sprintf(
                'Unsupported response reason phrase; must be a string, received %s',
                \is_object($reasonPhrase) ? \get_class($reasonPhrase) : \gettype($reasonPhrase)
            ));
        }

        if ($reasonPhrase === '' && isset($this->phrases[$code])) {
            $reasonPhrase = self::$phrases[$code];
        }

        $this->reasonPhrase = $reasonPhrase;
        $this->statusCode = (int) $code;
    }
634155
public void setCode(ExprCode code) {
        mCode = code;

        mStartPos = mCode.mStartPos;
        mCurIndex = mStartPos;
    }
352666
public function setStatusCode($code)
    {
        if (!is_int($code) || ($code < 100) || ($code > 599)) {
            throw new \BedRest\Rest\Exception("Invalid HTTP response code.");
        }

        $this->statusCode = $code;
    }
182254
public function setStatusCode($code)
    {
        static $sg = null;

        if (is_null($sg)) {
            $sg = new StatusGenerator();
        }

        $status = $sg->generate($code);

        if ($status !== false) {
            $this->append($status);
        }

        return $this;
    }
1184623
public function setStatus($code, $reasonPhrase = '')
    {
        $codeGroup = ResponseCode::getGroupFromCode($code);

        if ($codeGroup !== ResponseCode::GROUP_CLIENT_ERROR && $codeGroup !== ResponseCode::GROUP_SERVER_ERROR) {
            throw new \LogicException(__CLASS__ . ' accepts error codes only (4xx & 5xx).');
        }

        parent::setStatus($code, $reasonPhrase);
    }
324265
public function setStatus($code, $reasonPhrase = null)
    {
        $this->code = (int) $code;

        if ($reasonPhrase !== null) {
            $this->reasonPhrase = $reasonPhrase;
        } elseif (isset(Http::$codes[$this->code])) {
            $this->reasonPhrase = Http::$codes[$this->code];
        }
    }
1324386
def apply_status_code(status:)
      raise EntityClosedError if closed?
      case status.to_i
      when 429
        @throttle = true
        @error = true
        @fault = false
      when 400..499
        @error = true
        @throttle = false
        @fault = false
      when 500..599
        @fault = true
        @error = false
        @throttle = false
      end

      @http_response ||= {}
      @http_response[:status] = status.to_i
    end
907935
public function setStatus($code, $message = null)
    {
        if (!is_numeric($code) || !isset(self::$status_messages[$code]))
        {
            $code = is_scalar($code) ? $code : gettype($code);
            throw new \InvalidArgumentException(
                sprintf('Invalid status code provided: "%s"', $code)
            );
        }

        $this->_status_code    = (int) $code;
        $this->_status_message = trim(preg_replace('/\s+/', ' ',  $message));
        return $this;
    }
1259118
public function setStatusCode($statusCode, $statusText = null)
    {
        if ($statusText === null
            && array_key_exists((int) $statusCode, $this->statusTexts)
        ) {
            $statusText = $this->statusTexts[$statusCode];
        }

        $this->statusCode = (int) $statusCode;
        $this->statusText = (string) $statusText;
    }
1305403
public function setStatusCode($code)
    {
        // set status code
        $this->statusCode = $code;

        // lookup reason phrase by code and set
        $this->setStatusReasonPhrase(HttpProtocol::getStatusReasonPhraseByCode($code));
    }
695001
public void error(final int errorCode, final String message) {
		try {
			this.response.sendError(errorCode, message);
		} catch (final IOException e) {
			e.printStackTrace();
		}
	}
154088
public function setStatusCode($code)
    {
        $code = (int) $code;

        if (!array_key_exists($code, $this->validStatusCodes)) {
            throw new Exceptions\InvalidStatusCodeException(
                "'$code' is an invalid status code"
            );
        }

        $this->statusCode = $code;

        return $this;
    }
104669
public static HttpResponseStatus valueOf(int code) {
    switch (code) {
      case 100:
        return CONTINUE;
      case 101:
        return SWITCHING_PROTOCOLS;
      case 102:
        return PROCESSING;
      case 200:
        return OK;
      case 201:
        return CREATED;
      case 202:
        return ACCEPTED;
      case 203:
        return NON_AUTHORITATIVE_INFORMATION;
      case 204:
        return NO_CONTENT;
      case 205:
        return RESET_CONTENT;
      case 206:
        return PARTIAL_CONTENT;
      case 207:
        return MULTI_STATUS;
      case 300:
        return MULTIPLE_CHOICES;
      case 301:
        return MOVED_PERMANENTLY;
      case 302:
        return FOUND;
      case 303:
        return SEE_OTHER;
      case 304:
        return NOT_MODIFIED;
      case 305:
        return USE_PROXY;
      case 307:
        return TEMPORARY_REDIRECT;
      case 400:
        return BAD_REQUEST;
      case 401:
        return UNAUTHORIZED;
      case 402:
        return PAYMENT_REQUIRED;
      case 403:
        return FORBIDDEN;
      case 404:
        return NOT_FOUND;
      case 405:
        return METHOD_NOT_ALLOWED;
      case 406:
        return NOT_ACCEPTABLE;
      case 407:
        return PROXY_AUTHENTICATION_REQUIRED;
      case 408:
        return REQUEST_TIMEOUT;
      case 409:
        return CONFLICT;
      case 410:
        return GONE;
      case 411:
        return LENGTH_REQUIRED;
      case 412:
        return PRECONDITION_FAILED;
      case 413:
        return REQUEST_ENTITY_TOO_LARGE;
      case 414:
        return REQUEST_URI_TOO_LONG;
      case 415:
        return UNSUPPORTED_MEDIA_TYPE;
      case 416:
        return REQUESTED_RANGE_NOT_SATISFIABLE;
      case 417:
        return EXPECTATION_FAILED;
      case 422:
        return UNPROCESSABLE_ENTITY;
      case 423:
        return LOCKED;
      case 424:
        return FAILED_DEPENDENCY;
      case 425:
        return UNORDERED_COLLECTION;
      case 426:
        return UPGRADE_REQUIRED;
      case 500:
        return INTERNAL_SERVER_ERROR;
      case 501:
        return NOT_IMPLEMENTED;
      case 502:
        return BAD_GATEWAY;
      case 503:
        return SERVICE_UNAVAILABLE;
      case 504:
        return GATEWAY_TIMEOUT;
      case 505:
        return HTTP_VERSION_NOT_SUPPORTED;
      case 506:
        return VARIANT_ALSO_NEGOTIATES;
      case 507:
        return INSUFFICIENT_STORAGE;
      case 510:
        return NOT_EXTENDED;
    }

    final String reasonPhrase;

    if (code < 100) {
      reasonPhrase = "Unknown Status";
    } else if (code < 200) {
      reasonPhrase = "Informational";
    } else if (code < 300) {
      reasonPhrase = "Successful";
    } else if (code < 400) {
      reasonPhrase = "Redirection";
    } else if (code < 500) {
      reasonPhrase = "Client Error";
    } else if (code < 600) {
      reasonPhrase = "Server Error";
    } else {
      reasonPhrase = "Unknown Status";
    }

    return new HttpResponseStatus(code, reasonPhrase + " (" + code + ')');
  }
985060
public function setStatus(int $code): Response
    {
        # `Status::getText` will throw an exception for invalid status codes
        $this->statusText = Status::getText($code);
        $this->statusCode = $code;
        return $this;
    }