okhttp 3.3.1 发布,该版本主要是 Bug 修复,包括:
Fix: The plaintext check in HttpLoggingInterceptor incorrectly classified newline characters as control characters. This is fixed.
Fix: Don't crash reading non-ASCII characters in HTTP/2 headers or in cached HTTP headers.
Fix: Retain the response body when an attempt to open a web socket returns a non-101 response code.
okhttp 是一个 Java 的 HTTP+SPDY 客户端开发包,同时也支持 Android。
示例代码:[code]OkHttpClient client = new OkHttpClient();
String get(URL url) throws IOException {
HttpURLConnection connection = client.open(url);
InputStream in = null;
try {
// Read the response.
in = connection.getInputStream();
byte[] response = readFully(in);
return new String(response, "UTF-8");
} finally {
if (in != null) in.close();
}
}[/code]软件详情:https://github.com/square/okhttp
来自:开源中国社区

