mirror of
https://github.com/square/okhttp.git
synced 2025-11-24 18:41:06 +03:00
Omit the message from MockWebServer's HTTP/2 :status header (#3556)
This was a bug carried over from SPDY. Closes: https://github.com/square/okhttp/issues/3484
This commit is contained in:
@@ -219,9 +219,11 @@ public final class HttpLoggingInterceptor implements Interceptor {
|
||||
ResponseBody responseBody = response.body();
|
||||
long contentLength = responseBody.contentLength();
|
||||
String bodySize = contentLength != -1 ? contentLength + "-byte" : "unknown-length";
|
||||
logger.log("<-- " + response.code() + ' ' + response.message() + ' '
|
||||
+ response.request().url() + " (" + tookMs + "ms" + (!logHeaders ? ", "
|
||||
+ bodySize + " body" : "") + ')');
|
||||
logger.log("<-- "
|
||||
+ response.code()
|
||||
+ (response.message().isEmpty() ? "" : ' ' + response.message())
|
||||
+ ' ' + response.request().url()
|
||||
+ " (" + tookMs + "ms" + (!logHeaders ? ", " + bodySize + " body" : "") + ')');
|
||||
|
||||
if (logHeaders) {
|
||||
Headers headers = response.headers();
|
||||
|
||||
@@ -43,11 +43,13 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assume.assumeThat;
|
||||
|
||||
public final class HttpLoggingInterceptorTest {
|
||||
private static final MediaType PLAIN = MediaType.parse("text/plain; charset=utf-8");
|
||||
@@ -685,16 +687,16 @@ public final class HttpLoggingInterceptorTest {
|
||||
|
||||
server.enqueue(new MockResponse());
|
||||
Response response = client.newCall(request().build()).execute();
|
||||
assertEquals(Protocol.HTTP_2, response.protocol());
|
||||
assumeThat(response.protocol(), equalTo(Protocol.HTTP_2));
|
||||
|
||||
applicationLogs
|
||||
.assertLogEqual("--> GET " + url)
|
||||
.assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
|
||||
.assertLogMatch("<-- 200 " + url + " \\(\\d+ms, 0-byte body\\)")
|
||||
.assertNoMoreLogs();
|
||||
|
||||
networkLogs
|
||||
.assertLogEqual("--> GET " + url + " h2")
|
||||
.assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
|
||||
.assertLogMatch("<-- 200 " + url + " \\(\\d+ms, 0-byte body\\)")
|
||||
.assertNoMoreLogs();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user