class Server {

    private SubmitTransactionResponse submitTransaction(Transaction transaction, String url) throws IOException {
        URI transactionsUri = getUri(url);

        RequestBody formBody = new FormBody.Builder()
                .add("tx", transaction.toEnvelopeXdrBase64())
                .build();
        Request request = new Request.Builder()
                .url(transactionsUri.toString())
                .post(formBody)
                .build();

        Response response = null;
        try {
            response = httpClient.newCall(request).execute();

            if (response != null) {
                String location = response.header(LOCATION_HEADER);
                if (response.code() == TEMPORARY_REDIRECT && location != null) {
                    return submitTransaction(transaction, location);
                } else {
                    ResponseBody body = response.body();
                    if (body != null) {
                        String responseString = body.string();
                        return GsonSingleton.getInstance().fromJson(responseString, SubmitTransactionResponse.class);
                    }
                }
            }
        } finally {
            if (response != null) {
                response.close();
            }
        }
        return null;
    }

    public  Server(String uri);
    public  Server(String uri, OkHttpClient client);

}