{title:'Response Status', created:'8.1.0', updated:'9.0.0'}

After execution using {@link oajrc.RestRequest#run()} or {@link oajrc.RestRequest#complete()}, the following methods can be used to get the response status:

- {@link oajrc.RestResponse}
  - {@link oajrc.RestResponse#getStatusLine() getStatusLine()} returns {@link org.apache.http.StatusLine}
  - {@link oajrc.RestResponse#getStatusCode() getStatusCode()} returns int
  - {@link oajrc.RestResponse#getReasonPhrase() getReasonPhrase()} returns String
  - {@link oajrc.RestResponse#assertStatus() assertStatus()} returns {@link oajrc.assertion.FluentResponseStatusLineAssertion}

##### Example:

| // Only interested in status code. | int statusCode = client.get(URI).complete().getStatusCode();

Equivalent methods with mutable parameters are provided to allow access to status values without breaking fluent call chains.

##### Example:

| // Interested in multiple values. | Value<Integer> statusCode = Value. empty(); | Value<String> reasonPhrase = Value. empty(); | | client.get(URI).complete().getStatusCode(statusCode).getReasonPhrase(reasonPhrase); | System. err.println("statusCode="+statusCode.get()+", reasonPhrase="+reasonPhrase.get());

- If you are only interested in the response status and not the response body, be sure to use {@link oajrc.RestRequest#complete()} instead of {@link oajrc.RestRequest#run()} to make sure the response body gets automatically cleaned up. Otherwise you must consume the response yourself.

The assertion method is provided for quickly asserting status codes in fluent calls.

##### Example:

| // Status assertion using a static value. | String content1 = client.get(URI) | .run() | .assertStatus().asCode().isBetween(200,399) | .getContent().asString(); | | // Status assertion using a predicate. | String content2 = client.get(URI) | .run() | .assertStatus().asCode().is(x -> x<400) | .getContent().asString();