您的位置:首页 > 理论基础 > 计算机网络

okhttp基本使用

2016-05-07 02:43 399 查看
okhttp 基本使用

先看看几个重要的类

public final class Request {

private final HttpUrl url;

private final String method;

private final Headers headers;

private final RequestBody body;

private final Object tag;



}

public final class Response {

private final Request request;

private final Protocol protocol;

private final int code;

private final String message;

private final Handshake handshake;

private final Headers headers;

private final ResponseBody body;

private Response networkResponse;

private Response cacheResponse;

private final Response priorResponse;



}

使用步骤

1. OkHttpClient client= new OkHttpClient();

2. Request request = new Request.Builder().

url(“http://www.baidu.com“).

build();

3.Call call = client.newCall(request);

4. Response response=call.execute();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: