use of com.amazonaws.services.s3.Headers in project instructure-android by instructure.
the class APIHelperTest method parseLinkHeaderResponse.
@Test
public void parseLinkHeaderResponse() throws Exception {
Headers headers = new Headers.Builder().add("link: <https://mobiledev.instructure.com/api/v1/courses/123456/discussion_topics.json?page2>; rel=\"next\"").build();
LinkHeaders linkHeaders = APIHelper.parseLinkHeaderResponse(headers);
assertEquals(linkHeaders.nextUrl, "courses/123456/discussion_topics.json?page2");
}
use of com.amazonaws.services.s3.Headers in project hmftools by hartwigmedical.
the class ChunkHttpBuffer method readUrlBytes.
@NotNull
private ListenableFuture<byte[]> readUrlBytes(final long offset, final long count) {
final Headers httpHeaders = new Headers.Builder().add("Range", "bytes=" + offset + "-" + (offset + count - 1)).build();
final Request request = new Request.Builder().url(url).headers(httpHeaders).build();
final SettableFuture<byte[]> bytesFuture = SettableFuture.create();
httpClient.newCall(request).enqueue(retryingCallback(10, bytesFuture));
return bytesFuture;
}
use of com.amazonaws.services.s3.Headers in project YhLibraryForAndroid by android-coco.
the class LoggerInterceptor method logForRequest.
private void logForRequest(Request request) {
try {
String url = request.url().toString();
Headers headers = request.headers();
LogUtils.e(tag, "============请求'LogUtils=====开始");
LogUtils.e(tag, "请求方式 : " + request.method());
LogUtils.e(tag, "请求URL : " + url);
if (headers != null && headers.size() > 0) {
LogUtils.e(tag, "请求头 : " + headers.toString());
}
RequestBody requestBody = request.body();
if (requestBody != null) {
MediaType mediaType = requestBody.contentType();
if (mediaType != null) {
LogUtils.e(tag, "请求参数类型 : " + mediaType);
LogUtils.e(tag, "请求参数内容 : " + bodyToString(request).replace("&", " "));
// if (isText(mediaType))
// {
// LogUtils.e(tag, "请求参数内容 : " + bodyToString(request));
// } else
// {
// LogUtils.e(tag, "请求参数内容 : " + " 也许[文件部分],太大了太大了,忽略了!");
// }
}
}
LogUtils.e(tag, "============请求'LogUtils============结束");
} catch (Exception e) {
// e.printStackTrace();
}
}
use of com.amazonaws.services.s3.Headers in project BaseProject by feer921.
the class HttpLoggingInterceptor method logForRequest.
private void logForRequest(Request request, Connection connection) throws IOException {
boolean logBody = (printLevel == Level.BODY);
boolean logHeaders = (printLevel == Level.BODY || printLevel == Level.HEADERS);
RequestBody requestBody = request.body();
boolean hasRequestBody = requestBody != null;
Protocol protocol = connection != null ? connection.protocol() : Protocol.HTTP_1_1;
try {
String requestStartMessage = "--> " + request.method() + ' ' + request.url() + ' ' + protocol;
log(requestStartMessage);
if (logHeaders) {
log("\n**headers**");
Headers headers = request.headers();
for (int i = 0, count = headers.size(); i < count; i++) {
log("\t" + headers.name(i) + ": " + headers.value(i));
}
log("**end headers**");
if (logBody && hasRequestBody) {
if (isPlaintext(requestBody.contentType())) {
bodyToString(request);
} else {
log("\tbody: maybe [file part] , too large too print , ignored!");
}
}
}
} catch (Exception e) {
OkLogger.e(e);
} finally {
log("--> END " + request.method());
}
}
use of com.amazonaws.services.s3.Headers in project openhab-android by openhab.
the class OpenHABNotificationFragment method loadNotifications.
private void loadNotifications() {
Connection conn = ConnectionFactory.getConnection(Connection.TYPE_CLOUD);
if (conn == null) {
return;
}
startProgressIndicator();
mRequestHandle = conn.getAsyncHttpClient().get("/api/v1/notifications?limit=20", new MyHttpClient.ResponseHandler() {
@Override
public void onSuccess(Call call, int statusCode, Headers headers, byte[] responseBody) {
stopProgressIndicator();
Log.d(TAG, "Notifications request success");
try {
String jsonString = new String(responseBody, "UTF-8");
JSONArray jsonArray = new JSONArray(jsonString);
Log.d(TAG, jsonArray.toString());
mNotifications.clear();
for (int i = 0; i < jsonArray.length(); i++) {
try {
JSONObject sitemapJson = jsonArray.getJSONObject(i);
mNotifications.add(OpenHABNotification.fromJson(sitemapJson));
} catch (JSONException e) {
e.printStackTrace();
}
}
mNotificationAdapter.notifyDataSetChanged();
} catch (UnsupportedEncodingException | JSONException e) {
Log.d(TAG, e.getMessage(), e);
}
}
@Override
public void onFailure(Call call, int statusCode, Headers headers, byte[] responseBody, Throwable error) {
stopProgressIndicator();
Log.e(TAG, "Notifications request failure");
}
});
}
Aggregations