Search in sources :

Example 91 with Headers

use of com.amazonaws.services.s3.Headers in project hadoop by apache.

the class S3AFileSystem method newObjectMetadata.

/**
   * Create a new object metadata instance.
   * Any standard metadata headers are added here, for example:
   * encryption.
   * @return a new metadata instance
   */
public ObjectMetadata newObjectMetadata() {
    final ObjectMetadata om = new ObjectMetadata();
    setOptionalObjectMetadata(om);
    return om;
}
Also used : ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata)

Example 92 with Headers

use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.

the class EhEngine method getProfile.

public static ProfileParser.Result getProfile(@Nullable EhClient.Task task, OkHttpClient okHttpClient) throws Exception {
    String url = EhUrl.URL_FORUMS;
    Log.d(TAG, url);
    Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
    Call call = okHttpClient.newCall(request);
    // Put call
    if (null != task) {
        task.setCall(call);
    }
    String body = null;
    Headers headers = null;
    int code = -1;
    try {
        Response response = call.execute();
        code = response.code();
        headers = response.headers();
        body = response.body().string();
        return getProfileInternal(task, okHttpClient, ForumsParser.parse(body));
    } catch (Exception e) {
        throwException(call, code, headers, body, e);
        throw e;
    }
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Headers(okhttp3.Headers) Request(okhttp3.Request) EhException(com.hippo.ehviewer.client.exception.EhException) ParseException(com.hippo.ehviewer.client.exception.ParseException) CancelledException(com.hippo.ehviewer.client.exception.CancelledException) NoHAtHClientException(com.hippo.ehviewer.client.exception.NoHAtHClientException) StatusCodeException(com.hippo.network.StatusCodeException)

Example 93 with Headers

use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.

the class EhEngine method getGalleryToken.

public static String getGalleryToken(@Nullable EhClient.Task task, OkHttpClient okHttpClient, long gid, String gtoken, int page) throws Exception {
    JSONObject json = new JSONObject().put("method", "gtoken").put("pagelist", new JSONArray().put(new JSONArray().put(gid).put(gtoken).put(page + 1)));
    final RequestBody requestBody = RequestBody.create(MEDIA_TYPE_JSON, json.toString());
    String url = EhUrl.getApiUrl();
    Log.d(TAG, url);
    Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).post(requestBody).build();
    Call call = okHttpClient.newCall(request);
    // Put call
    if (null != task) {
        task.setCall(call);
    }
    String body = null;
    Headers headers = null;
    int code = -1;
    try {
        Response response = call.execute();
        code = response.code();
        headers = response.headers();
        body = response.body().string();
        return GalleryTokenApiParser.parse(body);
    } catch (Exception e) {
        throwException(call, code, headers, body, e);
        throw e;
    }
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) JSONObject(org.json.JSONObject) Headers(okhttp3.Headers) JSONArray(org.json.JSONArray) Request(okhttp3.Request) EhException(com.hippo.ehviewer.client.exception.EhException) ParseException(com.hippo.ehviewer.client.exception.ParseException) CancelledException(com.hippo.ehviewer.client.exception.CancelledException) NoHAtHClientException(com.hippo.ehviewer.client.exception.NoHAtHClientException) StatusCodeException(com.hippo.network.StatusCodeException) RequestBody(okhttp3.RequestBody)

Example 94 with Headers

use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.

the class EhEngine method getWhatsHot.

public static List<GalleryInfo> getWhatsHot(@Nullable EhClient.Task task, OkHttpClient okHttpClient) throws Exception {
    String url = EhUrl.HOST_E;
    Log.d(TAG, url);
    Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
    Call call = okHttpClient.newCall(request);
    // Put call
    if (null != task) {
        task.setCall(call);
    }
    String body = null;
    Headers headers = null;
    List<GalleryInfo> list;
    int code = -1;
    try {
        Response response = call.execute();
        code = response.code();
        headers = response.headers();
        body = response.body().string();
        list = WhatsHotParser.parse(body);
    } catch (Exception e) {
        throwException(call, code, headers, body, e);
        throw e;
    }
    if (list.size() > 0) {
        // Fill by api
        fillGalleryListByApi(task, okHttpClient, list);
    }
    for (GalleryInfo info : list) {
        info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
    }
    return list;
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Headers(okhttp3.Headers) Request(okhttp3.Request) GalleryInfo(com.hippo.ehviewer.client.data.GalleryInfo) EhException(com.hippo.ehviewer.client.exception.EhException) ParseException(com.hippo.ehviewer.client.exception.ParseException) CancelledException(com.hippo.ehviewer.client.exception.CancelledException) NoHAtHClientException(com.hippo.ehviewer.client.exception.NoHAtHClientException) StatusCodeException(com.hippo.network.StatusCodeException)

Example 95 with Headers

use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.

the class EhEngine method getGalleryPage.

public static GalleryPageParser.Result getGalleryPage(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
    Log.d(TAG, url);
    Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
    Call call = okHttpClient.newCall(request);
    // Put call
    if (null != task) {
        task.setCall(call);
    }
    String body = null;
    Headers headers = null;
    int code = -1;
    try {
        Response response = call.execute();
        code = response.code();
        headers = response.headers();
        body = response.body().string();
        return GalleryPageParser.parse(body);
    } catch (Exception e) {
        throwException(call, code, headers, body, e);
        throw e;
    }
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Headers(okhttp3.Headers) Request(okhttp3.Request) EhException(com.hippo.ehviewer.client.exception.EhException) ParseException(com.hippo.ehviewer.client.exception.ParseException) CancelledException(com.hippo.ehviewer.client.exception.CancelledException) NoHAtHClientException(com.hippo.ehviewer.client.exception.NoHAtHClientException) StatusCodeException(com.hippo.network.StatusCodeException)

Aggregations

Headers (okhttp3.Headers)128 Request (okhttp3.Request)61 Response (okhttp3.Response)54 Test (org.junit.Test)40 IOException (java.io.IOException)32 Call (okhttp3.Call)30 RequestBody (okhttp3.RequestBody)25 CancelledException (com.hippo.ehviewer.client.exception.CancelledException)20 EhException (com.hippo.ehviewer.client.exception.EhException)20 NoHAtHClientException (com.hippo.ehviewer.client.exception.NoHAtHClientException)20 ParseException (com.hippo.ehviewer.client.exception.ParseException)20 StatusCodeException (com.hippo.network.StatusCodeException)20 ResponseBody (okhttp3.ResponseBody)18 HttpHeaders (okhttp3.internal.http.HttpHeaders)18 MediaType (okhttp3.MediaType)15 ServiceResponseWithHeaders (com.microsoft.rest.ServiceResponseWithHeaders)14 HeaderResponseBoolHeaders (fixtures.header.models.HeaderResponseBoolHeaders)14 HeaderResponseByteHeaders (fixtures.header.models.HeaderResponseByteHeaders)14 HeaderResponseDateHeaders (fixtures.header.models.HeaderResponseDateHeaders)14 HeaderResponseDatetimeHeaders (fixtures.header.models.HeaderResponseDatetimeHeaders)14