List of usage examples for com.squareup.okhttp Request uri
public URI uri() throws IOException
From source file:io.minio.RequestSigner.java
License:Apache License
private String getCanonicalRequest(Request request, String bodySha256Hash, String signedHeaders) throws IOException { StringWriter canonicalWriter = new StringWriter(); PrintWriter canonicalPrinter = new PrintWriter(canonicalWriter, true); String method = request.method(); String path = request.uri().getPath(); String rawQuery = request.uri().getQuery(); if (rawQuery == null || rawQuery.isEmpty()) { rawQuery = ""; }//from ww w.j a v a 2 s .c om String query = getCanonicalQuery(rawQuery); canonicalPrinter.print(method + "\n"); canonicalPrinter.print(path + "\n"); canonicalPrinter.print(query + "\n"); Map<String, String> headers = getCanonicalHeaders(request); // new line already added for (Map.Entry<String, String> e : headers.entrySet()) { canonicalPrinter.write(e.getKey() + ":" + e.getValue() + '\n'); } canonicalPrinter.print("\n"); canonicalPrinter.print(signedHeaders + "\n"); canonicalPrinter.print(bodySha256Hash); canonicalPrinter.flush(); return canonicalWriter.toString(); }
From source file:org.jclouds.http.okhttp.OkHttpCommandExecutorService.java
License:Apache License
@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)); }/*from www .j av a 2s .c o m*/ 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(); }
From source file:quickbeer.android.next.network.utils.LoginRedirectInterceptor.java
License:Open Source License
@Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); Response response = chain.proceed(request); if (request.uri().getPath().equals("/Signin_r.asp") && response.isRedirect()) { Log.d(TAG, "Modifying response for login request"); return new Response.Builder().request(request).protocol(response.protocol()).code(200) .message(response.message()).handshake(response.handshake()).headers(response.headers()) .body(response.body()).networkResponse(response.networkResponse()).build(); }// w w w . jav a2s. c o m return response; }