Search in sources :

Example 1 with ResponseStream

use of com.lidroid.xutils.http.ResponseStream in project xUtils by wyouflf.

the class HttpFragment method testGetSync.

// 同步请求 必须在异步块儿中执行
private String testGetSync() {
    RequestParams params = new RequestParams();
    params.addQueryStringParameter("wd", "lidroid");
    HttpUtils http = new HttpUtils();
    http.configCurrentHttpCacheExpiry(1000 * 10);
    try {
        ResponseStream responseStream = http.sendSync(HttpRequest.HttpMethod.GET, "http://www.baidu.com/s", params);
        //Header[] headers = responseStream.getBaseResponse().getAllHeaders();
        return responseStream.readString();
    } catch (Exception e) {
        LogUtils.e(e.getMessage(), e);
    }
    return null;
}
Also used : HttpUtils(com.lidroid.xutils.HttpUtils) RequestParams(com.lidroid.xutils.http.RequestParams) HttpException(com.lidroid.xutils.exception.HttpException) DbException(com.lidroid.xutils.exception.DbException) ResponseStream(com.lidroid.xutils.http.ResponseStream)

Aggregations

HttpUtils (com.lidroid.xutils.HttpUtils)1 DbException (com.lidroid.xutils.exception.DbException)1 HttpException (com.lidroid.xutils.exception.HttpException)1 RequestParams (com.lidroid.xutils.http.RequestParams)1 ResponseStream (com.lidroid.xutils.http.ResponseStream)1