org.apache.hc.core5.http.HttpRequest.getPath()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.apache.hc.core5.http.HttpRequest.getPath()方法的一些代码示例,展示了HttpRequest.getPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getPath()方法的具体详情如下:
包路径:org.apache.hc.core5.http.HttpRequest
类名称:HttpRequest
方法名:getPath

HttpRequest.getPath介绍

[英]Returns URI path of this request message or null if not set.
[中]返回此请求消息的URI路径,如果未设置,则返回null。

代码示例

代码示例来源:origin: apache/httpcomponents-client

final String path = request.getPath();
if (path == null) {
  buf.append("/");

代码示例来源:origin: apache/httpcomponents-core

@Override
public String getPath() {
  return message.getPath();
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

@Override
public String getPath() {
  return message.getPath();
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

@Override
public T resolve(final HttpRequest request, final HttpContext context) throws MisdirectedRequestException {
  final URIAuthority authority = request.getAuthority();
  final String key = authority != null ? authority.getHostName().toLowerCase(Locale.ROOT) : null;
  final LookupRegistry<T> patternMatcher = getPatternMatcher(key);
  if (patternMatcher == null) {
    throw new MisdirectedRequestException("Not authoritative");
  }
  String path = request.getPath();
  final int i = path.indexOf('?');
  if (i != -1) {
    path = path.substring(0, i);
  }
  return patternMatcher.lookup(path);
}

代码示例来源:origin: apache/httpcomponents-core

@Override
public T resolve(final HttpRequest request, final HttpContext context) throws MisdirectedRequestException {
  final URIAuthority authority = request.getAuthority();
  final String key = authority != null ? authority.getHostName().toLowerCase(Locale.ROOT) : null;
  final LookupRegistry<T> patternMatcher = getPatternMatcher(key);
  if (patternMatcher == null) {
    throw new MisdirectedRequestException("Not authoritative");
  }
  String path = request.getPath();
  final int i = path.indexOf('?');
  if (i != -1) {
    path = path.substring(0, i);
  }
  return patternMatcher.lookup(path);
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

public AsyncPushConsumer get(final HttpRequest request) {
  Args.notNull(request, "Request");
  final URIAuthority authority = request.getAuthority();
  final String key = authority != null ? authority.getHostName().toLowerCase(Locale.ROOT) : null;
  final UriPatternMatcher<Supplier<AsyncPushConsumer>> patternMatcher = getPatternMatcher(key);
  if (patternMatcher == null) {
    return null;
  }
  String path = request.getPath();
  final int i = path.indexOf('?');
  if (i != -1) {
    path = path.substring(0, i);
  }
  final Supplier<AsyncPushConsumer> supplier = patternMatcher.lookup(path);
  return supplier != null ? supplier.get() : null;
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5-cache

final String path = request.getPath();
if (path == null) {
  buf.append("/");

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

@Override
public HttpRequest copy(final HttpRequest original) {
  if (original == null) {
    return null;
  }
  final BasicHttpRequest copy = new BasicHttpRequest(original.getMethod(), original.getPath());
  copy.setVersion(original.getVersion());
  for (final Iterator<Header> it = original.headerIterator(); it.hasNext(); ) {
    copy.addHeader(it.next());
  }
  copy.setScheme(original.getScheme());
  copy.setAuthority(original.getAuthority());
  return copy;
}

代码示例来源:origin: apache/httpcomponents-core

throw new ProtocolException("CONNECT request authority is not set");
if (message.getPath() != null) {
  throw new ProtocolException("CONNECT request path must be null");
  throw new ProtocolException("Request scheme is not set");
if (TextUtils.isBlank(message.getPath())) {
  throw new ProtocolException("Request path is not set");
  headers.add(new BasicHeader(H2PseudoRequestHeaders.AUTHORITY, message.getAuthority(), false));
headers.add(new BasicHeader(H2PseudoRequestHeaders.PATH, message.getPath(), false));

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

String path = request.getPath();
if (TextUtils.isEmpty(path)) {
  path = "/";

代码示例来源: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 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 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 testDefaultRequestConstructors() {
  HttpRequest request = new BasicHttpRequest("WHATEVER", "/");
  Assert.assertEquals("WHATEVER", request.getMethod());
  Assert.assertEquals("/", request.getPath());
  request = new BasicHttpRequest("GET", "/");
  Assert.assertEquals("GET", request.getMethod());
  Assert.assertEquals("/", request.getPath());
  try {
    new BasicHttpRequest("GET", (URI) null);
    Assert.fail("IllegalArgumentException should have been thrown");
  } catch (final IllegalArgumentException ex) {
    // expected
  }
}

代码示例来源: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());
}

相关文章