use of com.google.firebase.crashlytics.internal.network.HttpRequest in project GreenHouse by utsanjan.
the class DefaultCreateReportSpiCall method applyMultipartDataTo.
private HttpRequest applyMultipartDataTo(HttpRequest request, Report report) {
File[] files;
HttpRequest request2 = request.part(IDENTIFIER_PARAM, report.getIdentifier());
if (report.getFiles().length == 1) {
Logger.getLogger().d("Adding single file " + report.getFileName() + " to report " + report.getIdentifier());
return request2.part(FILE_PARAM, report.getFileName(), FILE_CONTENT_TYPE, report.getFile());
}
int i = 0;
for (File file : report.getFiles()) {
Logger.getLogger().d("Adding file " + file.getName() + " to report " + report.getIdentifier());
StringBuilder sb = new StringBuilder();
sb.append(MULTI_FILE_PARAM);
sb.append(i);
sb.append("]");
request2 = request2.part(sb.toString(), file.getName(), FILE_CONTENT_TYPE, file);
i++;
}
return request2;
}
use of com.google.firebase.crashlytics.internal.network.HttpRequest in project GreenHouse by utsanjan.
the class DefaultCreateReportSpiCall method applyHeadersTo.
private HttpRequest applyHeadersTo(HttpRequest request, CreateReportRequest requestData) {
HttpRequest request2 = request.header(AbstractSpiCall.HEADER_GOOGLE_APP_ID, requestData.googleAppId).header(AbstractSpiCall.HEADER_CLIENT_TYPE, AbstractSpiCall.ANDROID_CLIENT_TYPE).header(AbstractSpiCall.HEADER_CLIENT_VERSION, this.version);
Map<String, String> customHeaders = requestData.report.getCustomHeaders();
for (Map.Entry<String, String> entry : customHeaders.entrySet()) {
request2 = request2.header(entry);
}
return request2;
}
use of com.google.firebase.crashlytics.internal.network.HttpRequest in project GreenHouse by utsanjan.
the class DefaultCreateReportSpiCall method invoke.
// com.google.firebase.crashlytics.internal.report.network.CreateReportSpiCall
@Override
public boolean invoke(CreateReportRequest requestData, boolean dataCollectionToken) {
if (dataCollectionToken) {
HttpRequest httpRequest = getHttpRequest();
HttpRequest httpRequest2 = applyMultipartDataTo(applyHeadersTo(httpRequest, requestData), requestData.report);
Logger logger = Logger.getLogger();
logger.d("Sending report to: " + getUrl());
try {
HttpResponse httpResponse = httpRequest2.execute();
int statusCode = httpResponse.code();
Logger logger2 = Logger.getLogger();
logger2.d("Create report 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("Create report HTTP request failed.", ioe);
throw new RuntimeException(ioe);
}
} else {
throw new RuntimeException("An invalid data collection token was used.");
}
}
use of com.google.firebase.crashlytics.internal.network.HttpRequest in project GreenHouse by utsanjan.
the class DefaultSettingsSpiCall method invoke.
// com.google.firebase.crashlytics.internal.settings.network.SettingsSpiCall
@Override
public JSONObject invoke(SettingsRequest requestData, boolean dataCollectionToken) {
if (dataCollectionToken) {
try {
Map<String, String> queryParams = getQueryParamsFor(requestData);
HttpRequest httpRequest = getHttpRequest(queryParams);
HttpRequest httpRequest2 = applyHeadersTo(httpRequest, requestData);
Logger logger = this.logger;
logger.d("Requesting settings from " + getUrl());
Logger logger2 = this.logger;
logger2.d("Settings query params were: " + queryParams);
HttpResponse httpResponse = httpRequest2.execute();
Logger logger3 = this.logger;
logger3.d("Settings request ID: " + httpResponse.header(AbstractSpiCall.HEADER_REQUEST_ID));
JSONObject toReturn = handleResponse(httpResponse);
return toReturn;
} catch (IOException e) {
this.logger.e("Settings request failed.", e);
return null;
}
} else {
throw new RuntimeException("An invalid data collection token was used.");
}
}
use of com.google.firebase.crashlytics.internal.network.HttpRequest in project GreenHouse by utsanjan.
the class NativeCreateReportSpiCall method invoke.
// com.google.firebase.crashlytics.internal.report.network.CreateReportSpiCall
@Override
public boolean invoke(CreateReportRequest requestData, boolean dataCollectionToken) {
if (dataCollectionToken) {
HttpRequest httpRequest = getHttpRequest();
HttpRequest httpRequest2 = applyMultipartDataTo(applyHeadersTo(httpRequest, requestData.googleAppId), requestData.organizationId, requestData.report);
Logger logger = Logger.getLogger();
logger.d("Sending report to: " + getUrl());
try {
HttpResponse httpResponse = httpRequest2.execute();
int statusCode = httpResponse.code();
Logger logger2 = Logger.getLogger();
logger2.d("Result was: " + statusCode);
return ResponseParser.parse(statusCode) == 0;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} else {
throw new RuntimeException("An invalid data collection token was used.");
}
}
Aggregations