1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-27 18:21:14 +03:00

Log the full URL.

This commit is contained in:
Jake Wharton
2015-11-24 22:19:27 -05:00
parent cc829c1fa9
commit ebb0003968
2 changed files with 31 additions and 35 deletions

View File

@@ -17,7 +17,6 @@ package com.squareup.okhttp.logging;
import com.squareup.okhttp.Connection;
import com.squareup.okhttp.Headers;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
@@ -148,7 +147,7 @@ public final class HttpLoggingInterceptor implements Interceptor {
Connection connection = chain.connection();
Protocol protocol = connection != null ? connection.getProtocol() : Protocol.HTTP_1_1;
String requestStartMessage =
"--> " + request.method() + ' ' + requestPath(request.httpUrl()) + ' ' + protocol(protocol);
"--> " + request.method() + ' ' + request.httpUrl() + ' ' + protocol(protocol);
if (!logHeaders && hasRequestBody) {
requestStartMessage += " (" + requestBody.contentLength() + "-byte body)";
}
@@ -237,10 +236,4 @@ public final class HttpLoggingInterceptor implements Interceptor {
private static String protocol(Protocol protocol) {
return protocol == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1";
}
private static String requestPath(HttpUrl url) {
String path = url.encodedPath();
String query = url.encodedQuery();
return query != null ? (path + '?' + query) : path;
}
}