HttpCall extends StroomExtensionFunctionCall { Response execute(final String url, final String headers, final String mediaType, final String data, final String clientConfig) throws IOException { LOGGER.debug(() -> "Creating client"); final OkHttpClient client = httpClientCache.get(clientConfig); LOGGER.debug(() -> "Creating request builder"); Request.Builder builder = new Request.Builder().url(url); if (data != null && data.length() > 0) { final RequestBody body = RequestBody.create(data, MediaType.parse(mediaType)); builder = builder.post(body); } if (headers != null && headers.length() > 0) { final String[] parts = headers.split(HEADER_DELIMITER); for (final String part : parts) { int index = part.indexOf(HEADER_KV_DELIMITER); if (index > 0) { final String key = part.substring(0, index).trim(); final String value = part.substring(index + HEADER_KV_DELIMITER.length()).trim(); builder = builder.addHeader(key, value); } } } final Request request = builder.build(); return client.newCall(request).execute(); } @Inject  HttpCall(final HttpClientCache httpClientCache);   }
@Test void test() throws JsonProcessingException { final SSLConfig sslConfig = new SSLConfig(); sslConfig.setKeyStorePath("/Users/stroomdev66/work/stroom-6.0/stroom-ssl-test/client.jks"); sslConfig.setKeyStorePassword("password"); sslConfig.setTrustStorePath("/Users/stroomdev66/work/stroom-6.0/stroom-ssl-test/ca.jks"); sslConfig.setTrustStorePassword("password"); sslConfig.setHostnameVerificationEnabled(false); final ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); final String clientConfig = mapper.writeValueAsString(sslConfig); try (final CacheManager cacheManager = new CacheManagerImpl()) { HttpCall httpCall = new HttpCall(new HttpClientCache(cacheManager, new PipelineConfig())); try (Response response = httpCall.execute("https: System.out.println(response.body().string()); } catch (final Exception e) { fail(e.getMessage()); } } }