Search in sources :

Example 1 with HttpHeader

use of com.xiaoyunchengzhu.httpapi.net.HttpHeader in project HttpApiDemo by xiaoyunchengzhu.

the class OkhttpCallbackAdapter method onResponse.

@Override
public void onResponse(Call call, final Response response) {
    HttpResult httpResult = new HttpResult();
    httpResult.setInputStream(response.body().byteStream());
    httpResult.setContentLength(response.body().contentLength());
    HttpHeader httpHeader = new HttpHeader();
    Headers headers = response.headers();
    for (String name : headers.names()) {
        httpHeader.put(name, headers.get(name));
    }
    httpResult.setHttpHeader(httpHeader);
    httpResult.setProtocol(response.protocol().name());
    httpResult.setResponseCode(response.code());
    httpResult.setUrl(api.getUrl());
    callBackResult.success(api, httpResult);
}
Also used : HttpHeader(com.xiaoyunchengzhu.httpapi.net.HttpHeader) Headers(okhttp3.Headers) HttpResult(com.xiaoyunchengzhu.httpapi.net.HttpResult)

Aggregations

HttpHeader (com.xiaoyunchengzhu.httpapi.net.HttpHeader)1 HttpResult (com.xiaoyunchengzhu.httpapi.net.HttpResult)1 Headers (okhttp3.Headers)1