Added Host property to HttpHeaders
Added getHost/setHost to HttpHeaders, returning/taking a InetSocketAddress.
This commit is contained in:
committed by
Brian Clozel
parent
f2faf84f31
commit
ab7107c4c5
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -143,6 +144,24 @@ public class HttpHeadersTests {
|
||||
assertEquals("Invalid ETag header", "\"v2.6\"", headers.getFirst("ETag"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void host() {
|
||||
InetSocketAddress host = InetSocketAddress.createUnresolved("localhost", 8080);
|
||||
headers.setHost(host);
|
||||
assertEquals("Invalid Host header", host, headers.getHost());
|
||||
assertEquals("Invalid Host header", "localhost:8080", headers.getFirst("Host"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hostNoPort() {
|
||||
InetSocketAddress host = InetSocketAddress.createUnresolved("localhost", 0);
|
||||
headers.setHost(host);
|
||||
assertEquals("Invalid Host header", host, headers.getHost());
|
||||
assertEquals("Invalid Host header", "localhost", headers.getFirst("Host"));
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void illegalETag() {
|
||||
String eTag = "v2.6";
|
||||
|
||||
Reference in New Issue
Block a user