发布于 2016-05-30 02:23:42 | 206 次阅读 | 评论: 0 | 来源: 网友投递
okhttp HTTP+SPDY 客户端开发包
okhttp 是一个 Java 的 HTTP+SPDY 客户端开发包,同时也支持 Android。
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。
示例代码:
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(); } }