Skip to content

Commit

Permalink
Allow 1xx status codes (#871)
Browse files Browse the repository at this point in the history
* add support for 1xx status codes in Response

* allow for any status code
  • Loading branch information
maly7 authored and kdavisk6 committed Feb 6, 2019
1 parent db44bfe commit e8366d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion core/src/main/java/feign/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public final class Response implements Closeable {
private final Request request;

private Response(Builder builder) {
checkState(builder.status >= 200, "Invalid status code: %s", builder.status);
checkState(builder.request != null, "original request is required");
this.status = builder.status;
this.request = builder.request;
Expand Down
25 changes: 25 additions & 0 deletions core/src/test/java/feign/ResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package feign;

import feign.Request.HttpMethod;
import org.assertj.core.util.Lists;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -81,4 +82,28 @@ public void headersAreOptional() {
.build();
assertThat(response.headers()).isNotNull().isEmpty();
}

@Test
public void support1xxStatusCodes() {
Response response = Response.builder()
.status(103)
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.body((Response.Body) null)
.build();

assertThat(response.status()).isEqualTo(103);
}

@Test
public void statusCodesOfAnyValueAreAllowed() {
Lists.list(600, 50, 35600).forEach(statusCode -> {
Response response = Response.builder()
.status(statusCode)
.request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
.body((Response.Body) null)
.build();

assertThat(response.status()).isEqualTo(statusCode);
});
}
}

0 comments on commit e8366d0

Please sign in to comment.