OkHttp v3.7.0 发布,一个高效的Http客户端
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 like
co.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 implement
SecureRandom
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.open-open.com/news/view/7375d0fa
正文到此结束