Okhttp: Intercepter-logging: wrong protocol for real server using http2

Created on 9 Jun 2017  路  2Comments  路  Source: square/okhttp

What kind of issue is this?

  • [X] Bug report.

Summary

  • when using OkHttp with an HTTP2 server, the logging generated by logging-interceptor is wrong with regards to the protocol. it prints "http/1.1" when in reality it is "h2"
    (since in line https://github.com/square/okhttp/blob/a94f952d4fd612b649f0e1afbbcd06b7b991765b/okhttp/src/main/java/okhttp3/RealCall.java#L184 the connection is null, the connection will be null in
    https://github.com/square/okhttp/blob/master/okhttp-logging-interceptor/src/main/java/okhttp3/logging/HttpLoggingInterceptor.java#L154 , thus the result will be "http/1.1", which is extremely confusing and wrong.)
  • how to verify this is ? / reproduce this

Create a request to a http2 capable server, fire it off, and inspect the Response (there the protocol is set to "h2" as expected), and watch the interceptor log "http/1.1".

  • Write a failing test:
    its properly more a definition of using http1.1 as a default value, instead of saying "we do not know".
bug

Most helpful comment

Looking further, this is a problem with how the logging interceptor should behave when the protocol version is unknown? Yeah, we can fix this.

All 2 comments

Failing test?

Looking further, this is a problem with how the logging interceptor should behave when the protocol version is unknown? Yeah, we can fix this.

Was this page helpful?
0 / 5 - 0 ratings