OkHttp v3.3.0 發布,一個高效的Http客戶端

jopen 9年前發布 | 18K 次閱讀 OkHtt HTTP Android

OkHttp是一個高效的Http客戶端,在Android開發中被大量使用,主要有如下的特點:

  • 支持HTTP2/SPDY黑科技
  • socket自動選擇最好路線,并支持自動重連
  • 擁有自動維護的socket連接池,減少握手次數
  • 擁有隊列線程池,輕松寫并發
  • 擁有Interceptors輕松處理請求與響應(比如透明GZIP壓縮,LOGGING)
  • 基于Headers的緩存策略

更新日志

  • New: Response.sentRequestAtMillis() and receivedResponseAtMillis() methods track the system's local time when network calls are made. These replace the OkHttp-Sent-Millis and OkHttp-Sent-Millis headers that were present in earlier versions of OkHttp.
  • New: Accept user-provided trust managers in OkHttpClient.Builder. This allows OkHttp to satisfy its TLS requirements directly. Otherwise OkHttp will use reflection to extract the TrustManager from the SSLSocketFactory.
  • New: Support prerelease Java 9. This gets ALPN from the platform rather than relying on the alpn-boot bootclasspath override.
  • New: HttpLoggingInterceptor now logs connection failures.
  • New: Upgrade to Okio 1.8.0.

     <dependency>
       <groupId>com.squareup.okio</groupId>
       <artifactId>okio</artifactId>
       <version>1.8.0</version>
     </dependency>
  • Fix: Gracefully recover from a failure to rebuild the cache journal.

  • Fix: Don't corrupt cache entries when a cache entry is evicted while it is being updated.
  • Fix: Make logging more consistent throughout OkHttp.
  • Fix: Log plaintext bodies only. This uses simple heuristics to differentiate text from other data.
  • Fix: Recover from REFUSED_STREAM errors in HTTP/2. This should improve interoperability with Nginx 1.10.0, whichrefuses streams created before HTTP/2 settings have been acknowledged.
  • Fix: Improve recovery from failed routes.
  • Fix: Accommodate tunneling proxies that close the connection after an auth challenge.
  • Fix: Use the proxy authenticator when authenticating HTTP proxies. This regression was introduced in OkHttp 3.0.
  • Fix: Fail fast if network interceptors transform the response body such that closing it doesn't also close the underlying stream. We had a bug where OkHttp would attempt to reuse a connection but couldn't because it was still held by a prior request.
  • Fix: Ensure network interceptors always have access to the underlying connection.
  • Fix: Use X509TrustManagerExtensions on Android 17+.
  • Fix: Unblock waiting dispatchers on MockWebServer shutdown.

下載

 

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!