RequestBuilder (String url, String requestMethod, @Nullable String contentType, @Nullable ConnectionTuner tuner) { return new RequestBuilderImpl(url, rawConnection -> { HttpURLConnection connection = (HttpURLConnection)rawConnection; connection.setRequestMethod(requestMethod); connection.setDoOutput(true); if (contentType != null) connection.setRequestProperty("Content-Type", contentType); if (tuner != null) tuner.tune(connection); }); }