@@ -0,0 +1,2172 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public%0A * License, v. 2.0. If a copy of the MPL was not distributed with this%0A * file, You can obtain one at http://mozilla.org/MPL/2.0/. */%0A%0Apackage info.zamojski.soft.towercollector.io.network;%0A%0Aimport com.github.kevinsawicki.http.HttpRequest;%0Aimport com.github.kevinsawicki.http.HttpRequest.HttpRequestException;%0A%0Aimport trikita.log.Log;%0A%0Apublic class MozillaUploadClient extends ClientBase implements IUploadClient %7B%0A    private static final String TAG = MozillaUploadClient.class.getSimpleName();%0A%0A    private final String uploadUrl;%0A%0A    public MozillaUploadClient(String url, String apiKey) %7B%0A        this.uploadUrl = String.format(url, apiKey);%0A    %7D%0A%0A    @Override%0A    public RequestResult uploadMeasurements(String content) %7B%0A        Log.d(%22uploadMeasurements(): Sending post request%22);%0A        try %7B%0A            HttpRequest request = HttpRequest.post(uploadUrl)%0A                    .followRedirects(false)%0A                    .connectTimeout(CONN_TIMEOUT)%0A                    .readTimeout(READ_TIMEOUT);%0A            // add json as request content%0A            request.header(%22Content-Type%22, %22application/json%22);%0A            request.send(content);%0A            return handleResponse(request.code(), request.body());%0A        %7D catch (HttpRequestException ex) %7B%0A            Log.d(%22uploadMeasurements(): Errors encountered%22, ex);%0A            reportExceptionWithSuppress(ex);%0A            return RequestResult.Failure;%0A        %7D%0A    %7D%0A%0A    private RequestResult handleResponse(int code, String body) %7B%0A        if (code == 200) %7B%0A            return RequestResult.Success;%0A        %7D%0A        if (code %3E= 500 && code %3C= 599) %7B%0A            return RequestResult.ServerError;%0A        %7D%0A        if (code == 400 %7C%7C code == 403) %7B%0A            RuntimeException ex = new RequestException(body);%0A            reportException(ex);%0A            return RequestResult.ConfigurationError;%0A        %7D%0A        // don't report captive portals%0A        if (code != 302) %7B%0A            RuntimeException ex = new RequestException(body);%0A            reportException(ex);%0A        %7D%0A        return RequestResult.ConnectionError;%0A    %7D%0A%7D%0A

Add MozillaUploadClient.