本文整理了Java中org.apache.hc.core5.http.HttpRequest.getUri()
方法的一些代码示例,展示了HttpRequest.getUri()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getUri()
方法的具体详情如下:
包路径:org.apache.hc.core5.http.HttpRequest
类名称:HttpRequest
方法名:getUri
[英]Returns full request URI of this request message.
[中]返回此请求消息的完整请求URI。
代码示例来源:origin: apache/httpcomponents-client
uri = request.getUri();
} catch (final URISyntaxException ex) {
throw new ProtocolException(ex.getMessage(), ex);
代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5
@Override
public URI getUri() throws URISyntaxException {
return message.getUri();
}
代码示例来源:origin: apache/httpcomponents-core
@Override
public URI getUri() throws URISyntaxException {
return message.getUri();
}
代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5
@Override
public URI getLocationURI(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException {
Args.notNull(request, "HTTP request");
Args.notNull(response, "HTTP response");
Args.notNull(context, "HTTP context");
//get the location header to find out where to redirect to
final Header locationHeader = response.getFirstHeader("location");
if (locationHeader == null) {
throw new HttpException("Redirect location is missing");
}
final String location = locationHeader.getValue();
URI uri = createLocationURI(location);
try {
if (!uri.isAbsolute()) {
// Resolve location URI
uri = URIUtils.resolve(request.getUri(), uri);
}
} catch (final URISyntaxException ex) {
throw new ProtocolException(ex.getMessage(), ex);
}
return uri;
}
代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5
private static PasswordAuthentication getSystemCreds(
final String protocol,
final AuthScope authscope,
final Authenticator.RequestorType requestorType,
final HttpClientContext context) {
final HttpRequest request = context != null ? context.getRequest() : null;
URL targetHostURL;
try {
final URI uri = request != null ? request.getUri() : null;
targetHostURL = uri != null ? uri.toURL() : null;
} catch (final URISyntaxException | MalformedURLException ignore) {
targetHostURL = null;
}
// use null addr, because the authentication fails if it does not exactly match the expected realm's host
return Authenticator.requestPasswordAuthentication(
authscope.getHost(),
null,
authscope.getPort(),
protocol,
authscope.getRealm(),
translateAuthScheme(authscope.getAuthScheme()),
targetHostURL,
requestorType);
}
代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5
URI uri = request.getUri();
if (!uri.isAbsolute()) {
uri = URIUtils.rewriteURI(uri, route.getTargetHost(), true);
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestWithRelativeURI() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new URI("/stuff"));
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("/stuff", request.getPath());
Assert.assertEquals(null, request.getAuthority());
Assert.assertEquals(new URI("/stuff"), request.getUri());
}
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestWithUserInfo() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new URI("https://user:pwd@host:9443/stuff?param=value"));
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("/stuff?param=value", request.getPath());
Assert.assertEquals(new URIAuthority("user:pwd", "host", 9443), request.getAuthority());
Assert.assertEquals("https", request.getScheme());
Assert.assertEquals(new URI("https://host:9443/stuff?param=value"), request.getUri());
}
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestWithNoPath() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new URI("http://host"));
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("/", request.getPath());
Assert.assertEquals(new URIAuthority("host"), request.getAuthority());
Assert.assertEquals("http", request.getScheme());
Assert.assertEquals(new URI("http://host/"), request.getUri());
}
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestWithAbsoluteURI() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new URI("https://host:9443/stuff?param=value"));
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("/stuff?param=value", request.getPath());
Assert.assertEquals(new URIAuthority("host", 9443), request.getAuthority());
Assert.assertEquals("https", request.getScheme());
Assert.assertEquals(new URI("https://host:9443/stuff?param=value"), request.getUri());
}
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestBasics() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/stuff");
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("/stuff", request.getPath());
Assert.assertEquals(null, request.getAuthority());
Assert.assertEquals(new URI("/stuff"), request.getUri());
}
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestWithAuthority() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new HttpHost("http", "somehost", -1), "/stuff");
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("/stuff", request.getPath());
Assert.assertEquals(new URIAuthority("somehost"), request.getAuthority());
Assert.assertEquals(new URI("http://somehost/stuff"), request.getUri());
}
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestWithAbsoluteURIAsPath() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "https://host:9443/stuff?param=value");
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("/stuff?param=value", request.getPath());
Assert.assertEquals(new URIAuthority("host", 9443), request.getAuthority());
Assert.assertEquals("https", request.getScheme());
Assert.assertEquals(new URI("https://host:9443/stuff?param=value"), request.getUri());
}
代码示例来源:origin: apache/httpcomponents-core
@Test
public void testRequestWithAuthorityRelativePath() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", new HttpHost("http", "somehost", -1), "stuff");
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals("stuff", request.getPath());
Assert.assertEquals(new URIAuthority("somehost"), request.getAuthority());
Assert.assertEquals(new URI("http://somehost/stuff"), request.getUri());
}
内容来源于网络,如有侵权,请联系作者删除!