use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestDefaultH2RequestConverter method testConvertFromMessageMissingScheme.
@Test
public void testConvertFromMessageMissingScheme() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new HttpHost("host"), "/");
request.addHeader("Custom123", "Value");
request.setScheme(null);
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
Assertions.assertThrows(HttpException.class, () -> converter.convert(request), "Request scheme is not set");
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestDefaultH2RequestConverter method testConvertFromMessageConnectWithPath.
@Test
public void testConvertFromMessageConnectWithPath() throws Exception {
final HttpRequest request = new BasicHttpRequest("CONNECT", "/");
request.setAuthority(new URIAuthority("host"));
request.addHeader("Custom123", "Value");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
Assertions.assertThrows(HttpException.class, () -> converter.convert(request), "CONNECT request path must be null");
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestDefaultH2RequestConverter method testConvertFromFieldsProxyConnectionHeader.
@Test
public void testConvertFromFieldsProxyConnectionHeader() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new HttpHost("host"), "/");
request.addHeader("Proxy-Connection", "keep-alive");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
Assertions.assertThrows(HttpException.class, () -> converter.convert(request), "Header 'Proxy-Connection: Keep-Alive' is illegal for HTTP/2 messages");
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestDefaultH2RequestConverter method testConvertFromFieldsHostHeader.
@Test
public void testConvertFromFieldsHostHeader() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new HttpHost("host"), "/");
request.addHeader("Host", "host");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
Assertions.assertThrows(HttpException.class, () -> converter.convert(request), "Header 'Host: host' is illegal for HTTP/2 messages");
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestDefaultH2RequestConverter method testConvertFromFieldsUpgradeHeader.
@Test
public void testConvertFromFieldsUpgradeHeader() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new HttpHost("host"), "/");
request.addHeader("Upgrade", "example/1, foo/2");
final DefaultH2RequestConverter converter = new DefaultH2RequestConverter();
Assertions.assertThrows(HttpException.class, () -> converter.convert(request), "Header 'Upgrade: example/1, foo/2' is illegal for HTTP/2 messages");
}
Aggregations