com.squareup.okhttp.Request.uri()方法的使用及代码示例

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

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

Request.uri介绍

暂无

代码示例

代码示例来源:origin: org.echocat.marquardt/client

private void writeRequestTo(final Request request, final ByteArrayOutputStream bytesToSign) throws IOException {
  final byte[] requestBytes = (request.method() + " " + request.uri().getPath()).getBytes();
  bytesToSign.write(Ints.toByteArray(requestBytes.length));
  bytesToSign.write(requestBytes);
  for (final SignatureHeaders headerToInclude : SignatureHeaders.values()) {
    final String headerValue = request.header(headerToInclude.getHeaderName());
    if (headerValue != null) {
      final byte[] headerBytes = (headerToInclude.getHeaderName() + ":" + headerValue).getBytes();
      bytesToSign.write(Ints.toByteArray(headerBytes.length));
      bytesToSign.write(headerBytes);
    }
  }
}

代码示例来源:origin: liferay/liferay-mobile-sdk

@Override
public Request authenticate(Proxy proxy, Response response)
  throws IOException {
  Request request = response.request();
  Builder builder = request.newBuilder();
  try {
    BasicHeader authenticateHeader = new BasicHeader(
      Headers.WWW_AUTHENTICATE,
      response.header(Headers.WWW_AUTHENTICATE));
    DigestScheme scheme = new DigestScheme();
    scheme.processChallenge(authenticateHeader);
    BasicHttpRequest basicHttpRequest = new BasicHttpRequest(
      request.method(), request.uri().getPath());
    UsernamePasswordCredentials credentials =
      new UsernamePasswordCredentials(username, password);
    String authorizationHeader = scheme.authenticate(
      credentials, basicHttpRequest).getValue();
    builder.addHeader(Headers.AUTHORIZATION, authorizationHeader);
  }
  catch (Exception e) {
    throw new IOException(e);
  }
  return builder.build();
}

代码示例来源:origin: apache/jclouds

@Override
protected HttpResponse invoke(Request nativeRequest) throws IOException, InterruptedException {
 OkHttpClient requestScopedClient = globalClient.clone();
 requestScopedClient.setProxy(proxyForURI.apply(nativeRequest.uri()));
 Response response = requestScopedClient.newCall(nativeRequest).execute();
 HttpResponse.Builder<?> builder = HttpResponse.builder();
 builder.statusCode(response.code());
 builder.message(response.message());
 Builder<String, String> headerBuilder = ImmutableMultimap.builder();
 Headers responseHeaders = response.headers();
 for (String header : responseHeaders.names()) {
   headerBuilder.putAll(header, responseHeaders.values(header));
 }
 ImmutableMultimap<String, String> headers = headerBuilder.build();
 if (response.code() == 204 && response.body() != null) {
   response.body().close();
 } else {
   Payload payload = newInputStreamPayload(response.body().byteStream());
   contentMetadataCodec.fromHeaders(payload.getContentMetadata(), headers);
   builder.payload(payload);
 }
 builder.headers(filterOutContentHeaders(headers));
 return builder.build();
}

相关文章