Add support for non-standard status codes

Added support for status codes that do not occur in HttpStatus in
DefaultClientResponseBuilder and made ClientResponse::statusCode
ClientHttpResponse::getStatusCode @Nullable.

Closed gh-23366
This commit is contained in:
Arjen Poutsma
2019-07-30 17:39:44 +02:00
parent b2c56590dd
commit 29ef985411
8 changed files with 79 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,9 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* @author Arjen Poutsma
@@ -100,5 +102,19 @@ public class DefaultClientResponseBuilderTests {
.verifyComplete();
}
@Test
public void fromCustomStatus() {
ClientResponse other = ClientResponse.create(499, ExchangeStrategies.withDefaults())
.build();
ClientResponse result = ClientResponse.from(other)
.build();
assertEquals(499, result.rawStatusCode());
assertNull(result.statusCode());
}
}