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

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

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

HttpRequest.setAuthority介绍

[英]Sets authority of this request message.
[中]设置此请求消息的权限。

代码示例

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

@Override
public void setAuthority(final URIAuthority authority) {
  message.setAuthority(authority);
}

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

@Override
public void setAuthority(final URIAuthority authority) {
  message.setAuthority(authority);
}

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

httpRequest.setScheme(scheme);
try {
  httpRequest.setAuthority(URIAuthority.create(authority));
} catch (final URISyntaxException ex) {
  throw new ProtocolException(ex.getMessage(), ex);

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

@Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  final Header header = request.getHeader(HttpHeaders.HOST);
  if (header != null) {
    final URIAuthority authority;
    try {
      authority = URIAuthority.create(header.getValue());
    } catch (final URISyntaxException ex) {
      throw new ProtocolException(ex.getMessage(), ex);
    }
    request.setAuthority(authority);
  } else {
    final ProtocolVersion version = request.getVersion() != null ? request.getVersion() : HttpVersion.HTTP_1_1;
    if (version.greaterEquals(HttpVersion.HTTP_1_1)) {
      throw new ProtocolException("Host header is absent");
    }
  }
}

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

@Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  final Header header = request.getHeader(HttpHeaders.HOST);
  if (header != null) {
    final URIAuthority authority;
    try {
      authority = URIAuthority.create(header.getValue());
    } catch (final URISyntaxException ex) {
      throw new ProtocolException(ex.getMessage(), ex);
    }
    request.setAuthority(authority);
  } else {
    final ProtocolVersion version = request.getVersion() != null ? request.getVersion() : HttpVersion.HTTP_1_1;
    if (version.greaterEquals(HttpVersion.HTTP_1_1)) {
      throw new ProtocolException("Host header is absent");
    }
  }
}

相关文章