use of com.squareup.okhttp.Response in project remusic by aa112901.
the class HttpUtil method postNetease.
public static void postNetease(Context context, String j) {
try {
String action = "https://music.163.com/weapi/login/";
RequestBody formBody = new FormEncodingBuilder().add("params", "9NdyZTlp0Q/f1E1ora4tGM0uLYXqh7MD0mk7632ilWQvRDPZ02UkHrGFUccwW4HZYpacpPnmE+oMr/HI/vhuQvg8zYKgDP6NOaXG8nKDJpQTfOAiXT5KDrJOvb7ejSj/").add("encSeckey", "ae878167c394a959699c025a5c36043d0ae043c42d7f55fe4d1191c8ac9f3abe285b78c4a25ed6d9394a0ba0cb83a9a62de697199bd337f1de183bb07d6764a051495ea873ad615bb0a7e69f44d9168fc78ed1d61feb142ad06679dce58257ee9005756a18032ff499a4e24f7658bb59de2219f21f568301d43dba500e0c2d3b").build();
String json = "{\"params\": \"9NdyZTlp0Q/f1E1ora4tGM0uLYXqh7MD0mk7632ilWQvRDPZ02UkHrGFUccwW4HZYpacpPnmE+oMr/HI/vhuQvg8zYKgDP6NOaXG8nKDJpQTfOAiXT5KDrJOvb7ejSj/\", " + "\"encSecKey\": \"ae878167c394a959699c025a5c36043d0ae043c42d7f55fe4d1191c8ac9f3abe285b78c4a25ed6d9394a0ba0cb83a9a62de697199bd337f1de183bb07d6764a051495ea873ad615bb0a7e69f44d9168fc78ed1d61feb142ad06679dce58257ee9005756a18032ff499a4e24f7658bb59de2219f21f568301d43dba500e0c2d3b\"}";
RequestBody requestBody = RequestBody.create(MediaType.parse("JSON"), json);
Log.e("post", "p");
Request request = new Request.Builder().url(action).header("Content-Type", "application/x-www-form-urlencoded").header("Host", "music.163.com").header("Cookie", "appver=1.5.0.75771").header("Referer", "http://music.163.com/").header("Connection", "keep-alive").header("Accept-Encoding", "gzip,deflate").header("Accept", "*/*").header("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36").post(requestBody).build();
mOkHttpClient.setCookieHandler(new CookieManager(new PersistentCookieStore(context.getApplicationContext()), CookiePolicy.ACCEPT_ALL));
Response response = mOkHttpClient.newCall(request).execute();
if (response.isSuccessful()) {
Log.e("respose", response.body().string());
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.squareup.okhttp.Response in project remusic by aa112901.
the class HttpUtil method getOut.
public static void getOut(final String url) {
try {
mOkHttpClient.setConnectTimeout(1000, TimeUnit.MINUTES);
mOkHttpClient.setReadTimeout(1000, TimeUnit.MINUTES);
Request request = new Request.Builder().url(url).build();
Response response = mOkHttpClient.newCall(request).execute();
if (response.isSuccessful()) {
FileOutputStream fo = new FileOutputStream("/storage/emulated/0/" + "gedangein" + ".json");
byte[] c = new byte[1024];
while (response.body().source().read(c) != -1) {
fo.write(c);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.squareup.okhttp.Response in project robovm by robovm.
the class Job method run.
@Override
public void run() {
try {
sendRequest();
Response response = readResponse();
responseReceiver.onResponse(response);
} catch (IOException e) {
responseReceiver.onFailure(new Failure.Builder().request(request).exception(e).build());
} finally {
connection.disconnect();
dispatcher.finished(this);
}
}
use of com.squareup.okhttp.Response in project AisenWeiBo by wangdan.
the class PictureSizeHttpUtility method doGet.
@Override
public <T> T doGet(HttpConfig config, Setting action, Params urlParams, Class<T> responseCls) throws TaskException {
if (GlobalContext.getInstance() == null || SystemUtils.getNetworkType(GlobalContext.getInstance()) == SystemUtils.NetWorkType.none)
return null;
String url = urlParams.getParameter("path");
PictureSize size = new PictureSize();
size.setUrl(url);
Request request = new Request.Builder().url(url).build();
try {
Response response = GlobalContext.getOkHttpClient().newCall(request).execute();
if (!(response.code() == HttpURLConnection.HTTP_OK || response.code() == HttpURLConnection.HTTP_PARTIAL)) {
throw new TaskException(String.valueOf(TaskException.TaskError.failIOError));
} else {
// 图片大小
String header = response.header("Content-Length");
int length = Integer.parseInt(header);
size.setSize(length);
SinaDB.getDB().insert(null, size);
Logger.d(TAG, String.format("图片大小 %s", String.valueOf(size.getSize())));
}
} catch (Exception e) {
throw new TaskException(String.valueOf(TaskException.TaskError.failIOError));
}
return (T) size;
}
use of com.squareup.okhttp.Response in project pinpoint by naver.
the class HttpEngineReadResponseMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
if (!validate(target)) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
if (statusCode) {
// type check validate();
Response response = ((UserResponseGetter) target)._$PINPOINT$_getUserResponse();
if (response != null) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, response.code());
}
}
} finally {
trace.traceBlockEnd();
}
}
Aggregations