{8.2.0-new} Response Status

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

- {@link oajr.client2.RestResponse}
  - {@link oajr.client2.RestResponse#getStatusLine() getStatusLine()} returns {@link org.apache.http.StatusLine}
  - {@link oajr.client2.RestResponse#getStatusCode() getStatusCode()} returns int
  - {@link oajr.client2.RestResponse#getReasonPhrase() getReasonPhrase()} returns String
  - {@link oajr.client2.RestResponse#assertStatus() assertStatus()} returns {@link oajr.client2.RestResponseStatusLineAssertion}

##### 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. Mutable<Integer> statusCode = Mutable.create(); Mutable<String> reasonPhrase = Mutable.create(); 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 oajr.client2.RestRequest#complete()} instead of {@link oajr.client2.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 body1 = client.get(URI) .run() .assertStatus().code().isBetween(200,399) .getBody().asString(); // Status assertion using a predicate. String body2 = client.get(URI) .run() .assertStatus().code().passes(x -> x<400) .getBody().asString();