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

jopen 7年前發布 | 14K 次閱讀 OkHtt HTTP Android

 

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

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

更新日志

  • OkHttp no longer recovers from TLS handshake failures by attempting a TLSv1 connection. The fallback was necessary for servers that implemented version negotiation incorrectly. Now that 99.99% of servers do it right this fallback is obsolete.
  • Fix: Do not honor cookies set on a public domain. Previously a malicious site could inject cookies on top-level domains likeco.uk because our cookie parser didn't honor the public suffix list. Alongside this fix is a new API,HttpUrl.topPrivateDomain(), which returns the privately domain name if the URL has one.
  • Fix: Change MediaType.charset() to return null for unexpected charsets.
  • Fix: Don't skip cache invalidation if the invalidating response has no body.
  • Fix: Don't use a cryptographic random number generator for web sockets. Some Android devices implementSecureRandom incorrectly!
  • Fix: Correctly canonicalize IPv6 addresses in HttpUrl. This prevented OkHttp from trusting HTTPS certificates issued to certain IPv6 addresses.
  • Fix: Don't reuse connections after an unsuccessful Expect: 100-continue.
  • Fix: Handle either TLS_ or SSL_ prefixes for cipher suite names. This is necessary for IBM JVMs that use the SSL_ prefix exclusively.
  • Fix: Reject HTTP/2 data frames if the stream ID is 0.
  • New: Connection coalescing. OkHttp may reuse HTTP/2 connections across calls that share an IP address and HTTPS certificate, even if their domain names are different.
  • New: MockWebServer's RecordedRequest exposes the requested HttpUrl with getRequestUrl().

下載

本站原創,轉載時保留以下信息:
本文轉自:深度開源(open-open.com)
原文地址:http://www.baiduhome.net/news/view/7375d0fa

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