valueOf static method

HttpStatus valueOf(
  1. int code
)

Returns the http status of code.

Returns HttpStatus.unknown if code is not defined in this enum so that unexpected status codes never crash response handling.

Implementation

static HttpStatus valueOf(final int code) {
  for (final status in values) {
    if (status.code == code) {
      return status;
    }
  }

  return unknown;
}