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

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

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

HttpRequest.getVersion介绍

暂无

代码示例

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

private void transferEncodingIsNotReturnedTo1_0Client(
    final HttpRequest originalRequest, final HttpResponse response) {
  final ProtocolVersion version = originalRequest.getVersion() != null ? originalRequest.getVersion() : HttpVersion.DEFAULT;
  if (version.compareToVersion(HttpVersion.HTTP_1_1) >= 0) {
    return;
  }
  removeResponseTransferEncoding(response);
}

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

protected boolean requestVersionIsTooLow(final HttpRequest request) {
  final ProtocolVersion requestProtocol = request.getVersion();
  return requestProtocol != null && requestProtocol.compareToVersion(HttpVersion.HTTP_1_1) < 0;
}

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

final String method = request.getMethod();
final ProtocolVersion pv = request.getVersion() != null ? request.getVersion() : HttpVersion.DEFAULT;
if (HttpVersion.HTTP_1_1.compareToVersion(pv) != 0) {
  log.debug("non-HTTP/1.1 request is not serveable from cache");

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

protected boolean requestMinorVersionIsTooHighMajorVersionsMatch(final HttpRequest request) {
  final ProtocolVersion requestProtocol = request.getVersion();
  if (requestProtocol == null) {
    return false;
  }
  if (requestProtocol.getMajor() != HttpVersion.HTTP_1_1.getMajor()) {
    return false;
  }
  if (requestProtocol.getMinor() > HttpVersion.HTTP_1_1.getMinor()) {
    return true;
  }
  return false;
}

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

final ProtocolVersion version = request.getVersion() != null ? request.getVersion() : HttpVersion.DEFAULT;
if (version.compareToVersion(HttpVersion.HTTP_1_1) > 0) {
  if (log.isDebugEnabled()) {

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

public static boolean equivalent(final HttpRequest r1, final HttpRequest r2) {
  return equivalent(r1.getVersion(), r2.getVersion()) &&
      LangUtils.equals(r1.getMethod(), r2.getMethod()) &&
      LangUtils.equals(r1.getRequestUri(), r2.getRequestUri()) &&
      isEndToEndHeaderSubset(r1, r2);
}

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

@Test
public void upgrades1_0RequestTo1_1() throws Exception {
  final HttpRequest req = new BasicHttpRequest("GET", "/");
  req.setVersion(HttpVersion.HTTP_1_0);
  final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req);
  impl.makeRequestCompliant(wrapper);
  assertEquals(HttpVersion.HTTP_1_1, wrapper.getVersion());
}

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

@Test
public void downgrades1_2RequestTo1_1() throws Exception {
  final HttpRequest req = new BasicHttpRequest("GET", "/");
  req.setVersion(new ProtocolVersion("HTTP", 1, 2));
  final HttpRequest wrapper = RequestCopier.INSTANCE.copy(req);
  impl.makeRequestCompliant(wrapper);
  assertEquals(HttpVersion.HTTP_1_1, wrapper.getVersion());
}

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

private void transferEncodingIsNotReturnedTo1_0Client(
    final HttpRequest originalRequest, final HttpResponse response) {
  final ProtocolVersion version = originalRequest.getVersion() != null ? originalRequest.getVersion() : HttpVersion.DEFAULT;
  if (version.compareToVersion(HttpVersion.HTTP_1_1) >= 0) {
    return;
  }
  removeResponseTransferEncoding(response);
}

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

protected boolean requestVersionIsTooLow(final HttpRequest request) {
  final ProtocolVersion requestProtocol = request.getVersion();
  return requestProtocol != null && requestProtocol.compareToVersion(HttpVersion.HTTP_1_1) < 0;
}

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

public RequestLine(final HttpRequest request) {
  super();
  Args.notNull(request, "Request");
  this.method = request.getMethod();
  this.uri = request.getRequestUri();
  this.protoversion = request.getVersion() != null ? request.getVersion() : HttpVersion.HTTP_1_1;
}

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

public RequestLine(final HttpRequest request) {
  super();
  Args.notNull(request, "Request");
  this.method = request.getMethod();
  this.uri = request.getRequestUri();
  this.protoversion = request.getVersion() != null ? request.getVersion() : HttpVersion.HTTP_1_1;
}

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

protected boolean requestMinorVersionIsTooHighMajorVersionsMatch(final HttpRequest request) {
  final ProtocolVersion requestProtocol = request.getVersion();
  if (requestProtocol == null) {
    return false;
  }
  if (requestProtocol.getMajor() != HttpVersion.HTTP_1_1.getMajor()) {
    return false;
  }
  if (requestProtocol.getMinor() > HttpVersion.HTTP_1_1.getMinor()) {
    return true;
  }
  return false;
}

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

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

@Override
public void process(final HttpRequest request, final EntityDetails entity, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  if (!request.containsHeader(HttpHeaders.EXPECT)) {
    final ProtocolVersion version = request.getVersion() != null ? request.getVersion() : HttpVersion.HTTP_1_1;
    // Do not send the expect header if request body is known to be empty
    if (entity != null
        && entity.getContentLength() != 0 && !version.lessEquals(HttpVersion.HTTP_1_0)) {
      final HttpClientContext clientContext = HttpClientContext.adapt(context);
      final RequestConfig config = clientContext.getRequestConfig();
      if (config.isExpectContinueEnabled()) {
        request.addHeader(HttpHeaders.EXPECT, HeaderElements.CONTINUE);
      }
    }
  }
}

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

@Override
protected void writeHeadLine(final T message, final CharArrayBuffer lineBuf) throws IOException {
  lineBuf.clear();
  final ProtocolVersion transportVersion = message.getVersion();
  getLineFormatter().formatRequestLine(lineBuf, new RequestLine(
      message.getMethod(),
      message.getRequestUri(),
      transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1));
}

代码示例来源: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: org.apache.httpcomponents.client5/httpclient5

public static SimpleHttpRequest copy(final HttpRequest original) {
  Args.notNull(original, "HTTP request");
  final SimpleHttpRequest copy = new SimpleHttpRequest(original.getMethod(), original.getRequestUri());
  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

@Override
protected void writeHeadLine(final T message, final CharArrayBuffer lineBuf) throws IOException {
  lineBuf.clear();
  final ProtocolVersion transportVersion = message.getVersion();
  getLineFormatter().formatRequestLine(lineBuf, new RequestLine(
      message.getMethod(),
      message.getRequestUri(),
      transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1));
}

相关文章