OkHttp v3.3.0 发布,一个高效的Http客户端

jopen 8年前
   <p style="text-align:center"><img alt="" src="https://simg.open-open.com/show/a6dcb578e17e7b0fb37f34f8fe57f157.png" /></p>    <p>OkHttp是一个高效的Http客户端,在Android开发中被大量使用,主要有如下的特点:</p>    <ul>     <li>支持HTTP2/SPDY黑科技</li>     <li>socket自动选择最好路线,并支持自动重连</li>     <li>拥有自动维护的socket连接池,减少握手次数</li>     <li>拥有队列线程池,轻松写并发</li>     <li>拥有Interceptors轻松处理请求与响应(比如透明GZIP压缩,LOGGING)</li>     <li>基于Headers的缓存策略</li>    </ul>    <h2>更新日志</h2>    <ul>     <li>New: <code>Response.sentRequestAtMillis()</code> and <code>receivedResponseAtMillis()</code> methods track the system's local time when network calls are made. These replace the <code>OkHttp-Sent-Millis</code> and <code>OkHttp-Sent-Millis</code> headers that were present in earlier versions of OkHttp.</li>     <li>New: Accept user-provided trust managers in <code>OkHttpClient.Builder</code>. This allows OkHttp to satisfy its TLS requirements directly. Otherwise OkHttp will use reflection to extract the <code>TrustManager</code> from the <code>SSLSocketFactory</code>.</li>     <li>New: Support prerelease Java 9. This gets ALPN from the platform rather than relying on the alpn-boot bootclasspath override.</li>     <li>New: <code>HttpLoggingInterceptor</code> now logs connection failures.</li>     <li> <p>New: Upgrade to Okio 1.8.0.</p> <pre>   <dependency>     <groupId>com.squareup.okio</groupId>     <artifactId>okio</artifactId>     <version>1.8.0</version>   </dependency></pre> </li>     <li> <p>Fix: Gracefully recover from a failure to rebuild the cache journal.</p> </li>     <li>Fix: Don't corrupt cache entries when a cache entry is evicted while it is being updated.</li>     <li>Fix: Make logging more consistent throughout OkHttp.</li>     <li>Fix: Log plaintext bodies only. This uses simple heuristics to differentiate text from other data.</li>     <li>Fix: Recover from <code>REFUSED_STREAM</code> errors in HTTP/2. This should improve interoperability with Nginx 1.10.0, which<a href="/misc/goto?guid=4958990783824674640">refuses</a> streams created before HTTP/2 settings have been acknowledged.</li>     <li>Fix: Improve recovery from failed routes.</li>     <li>Fix: Accommodate tunneling proxies that close the connection after an auth challenge.</li>     <li>Fix: Use the proxy authenticator when authenticating HTTP proxies. This regression was introduced in OkHttp 3.0.</li>     <li>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.</li>     <li>Fix: Ensure network interceptors always have access to the underlying connection.</li>     <li>Fix: Use <code>X509TrustManagerExtensions</code> on Android 17+.</li>     <li>Fix: Unblock waiting dispatchers on MockWebServer shutdown.</li>    </ul>    <h2>下载</h2>    <ul>     <li><strong><a href="/misc/goto?guid=4958990783940407551">v3.3.0JAR</a></strong></li>     <li><a href="/misc/goto?guid=4958990784043171476" rel="nofollow"><strong>Source code</strong> (zip)</a></li>     <li><a href="/misc/goto?guid=4958990784158944622" rel="nofollow"><strong>Source code</strong> (tar.gz)</a></li>    </ul>    <p> </p>