use of com.kymjs.rxvolley.toolbox.HttpParamsEntry in project yoo_home_Android by culturer.
the class OkHttpStack method performRequest.
@Override
public URLHttpResponse performRequest(Request<?> request, ArrayList<HttpParamsEntry> additionalHeaders) throws IOException {
OkHttpClient client = mClient.clone();
int timeoutMs = request.getTimeoutMs();
client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
okHttpRequestBuilder.url(request.getUrl());
for (final HttpParamsEntry entry : request.getHeaders()) {
okHttpRequestBuilder.addHeader(entry.k, entry.v);
}
for (final HttpParamsEntry entry : additionalHeaders) {
okHttpRequestBuilder.addHeader(entry.k, entry.v);
}
setConnectionParametersForRequest(okHttpRequestBuilder, request);
com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
Call okHttpCall = client.newCall(okHttpRequest);
Response okHttpResponse = okHttpCall.execute();
return responseFromConnection(okHttpResponse);
}
use of com.kymjs.rxvolley.toolbox.HttpParamsEntry in project yoo_home_Android by culturer.
the class HttpParams method getUrlParams.
public StringBuilder getUrlParams() {
StringBuilder result = new StringBuilder();
boolean isFirst = true;
Collections.sort(urlParams);
for (HttpParamsEntry entry : urlParams) {
if (!isFirst) {
result.append("&");
} else {
result.append("?");
isFirst = false;
}
try {
result.append(URLEncoder.encode(entry.k, CHARSET)).append("=").append(URLEncoder.encode(entry.v, CHARSET));
} catch (UnsupportedEncodingException e) {
result.append(entry.k).append("=").append(entry.v);
}
}
return result;
}
use of com.kymjs.rxvolley.toolbox.HttpParamsEntry in project yoo_home_Android by culturer.
the class OkHttpStack method performRequest.
@Override
public URLHttpResponse performRequest(Request<?> request, ArrayList<HttpParamsEntry> additionalHeaders) throws IOException {
int timeoutMs = request.getTimeoutMs();
OkHttpClient client = mClient.newBuilder().readTimeout(timeoutMs, TimeUnit.MILLISECONDS).connectTimeout(timeoutMs, TimeUnit.MILLISECONDS).writeTimeout(timeoutMs, TimeUnit.MILLISECONDS).build();
okhttp3.Request.Builder okHttpRequestBuilder = new okhttp3.Request.Builder();
okHttpRequestBuilder.url(request.getUrl());
for (final HttpParamsEntry entry : request.getHeaders()) {
okHttpRequestBuilder.addHeader(entry.k, entry.v);
}
for (final HttpParamsEntry entry : additionalHeaders) {
okHttpRequestBuilder.addHeader(entry.k, entry.v);
}
setConnectionParametersForRequest(okHttpRequestBuilder, request);
okhttp3.Request okHttpRequest = okHttpRequestBuilder.build();
Call okHttpCall = client.newCall(okHttpRequest);
Response okHttpResponse = okHttpCall.execute();
return responseFromConnection(okHttpResponse);
}
use of com.kymjs.rxvolley.toolbox.HttpParamsEntry in project yoo_home_Android by culturer.
the class FileRequest method getHeaders.
@Override
public ArrayList<HttpParamsEntry> getHeaders() {
mHeaders.add(new HttpParamsEntry("Range", "bytes=" + mTemporaryFile.length() + "-"));
mHeaders.add(new HttpParamsEntry("Accept-Encoding", "identity"));
return mHeaders;
}
use of com.kymjs.rxvolley.toolbox.HttpParamsEntry in project yoo_home_Android by culturer.
the class HttpParams method put.
/**
* 添加文本参数
*/
public void put(final String key, final String value) {
urlParams.add(new HttpParamsEntry(key, value));
writeToOutputStream(key, value.getBytes(), TYPE_TEXT_CHARSET, BIT_ENCODING, "");
}
Aggregations