- 授权协议: Apache
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: http://square.github.io/okhttp/
- 软件文档: https://github.com/square/okhttp/wiki
- 官方下载: https://github.com/square/okhttp/releases
软件介绍
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();
}
}
