当我在寻找Spdy客户端时,我找到了okhttp。我刚开始尝试它。我的问题是当我按如下所示运行GetExample.java时,
import java.io.IOException;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
public class GetExample {
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.protocol());
return response.body().string();
}
public static void main(String[] args) throws IOException {
GetExample example = new GetExample();
String response = example.run("https://www.google.com");
System.out.println(response.length());
}
}
response.protocol()总是返回,http / 1.1,为什么它不返回spdy?有没有办法强迫客户只使用spdy?
答案 0 :(得分:-1)
您是在使用桌面Java还是Android? SPDY需要在桌面Java上使用名为ALPN-boot的库。在Android上,您需要v5.0或更高版本,这是包含稳定ALPN实现的最早版本。更多细节在这里: