Search in sources :

Example 6 with HttpRequest

use of com.google.firebase.crashlytics.internal.network.HttpRequest in project GreenHouse by utsanjan.

the class AbstractAppSpiCall method invoke.

// com.google.firebase.crashlytics.internal.settings.network.AppSpiCall
@Override
public boolean invoke(AppRequestData requestData, boolean dataCollectionToken) {
    if (dataCollectionToken) {
        HttpRequest httpRequest = applyMultipartDataTo(applyHeadersTo(getHttpRequest(), requestData), requestData);
        Logger logger = Logger.getLogger();
        logger.d("Sending app info to " + getUrl());
        try {
            HttpResponse httpResponse = httpRequest.execute();
            int statusCode = httpResponse.code();
            String kind = "POST".equalsIgnoreCase(httpRequest.method()) ? "Create" : "Update";
            Logger logger2 = Logger.getLogger();
            logger2.d(kind + " app request ID: " + httpResponse.header(AbstractSpiCall.HEADER_REQUEST_ID));
            Logger logger3 = Logger.getLogger();
            logger3.d("Result was " + statusCode);
            return ResponseParser.parse(statusCode) == 0;
        } catch (IOException ioe) {
            Logger.getLogger().e("HTTP request failed.", ioe);
            throw new RuntimeException(ioe);
        }
    } else {
        throw new RuntimeException("An invalid data collection token was used.");
    }
}
Also used : HttpRequest(com.google.firebase.crashlytics.internal.network.HttpRequest) HttpResponse(com.google.firebase.crashlytics.internal.network.HttpResponse) IOException(java.io.IOException) Logger(com.google.firebase.crashlytics.internal.Logger)

Aggregations

HttpRequest (com.google.firebase.crashlytics.internal.network.HttpRequest)6 Logger (com.google.firebase.crashlytics.internal.Logger)4 HttpResponse (com.google.firebase.crashlytics.internal.network.HttpResponse)4 IOException (java.io.IOException)4 File (java.io.File)1 Map (java.util.Map)1 JSONObject (org.json.JSONObject)1