Source:
private byte[] makeRequest(FContext context, byte[] requestPayload) throws TTransportException { String encoded = Base64.encodeBase64String(requestPayload); StringEntity requestEntity = new StringEntity(encoded, ContentType.create("application/x-frugal", "utf-8")); HttpPost request = new HttpPost(url); request.setHeader("accept", "application/x-frugal"); request.setHeader("content-transfer-encoding", "base64"); if (responseSizeLimit > 0) { request.setHeader("x-frugal-payload-limit", Integer.toString(responseSizeLimit)); } request.setEntity(requestEntity); request.setConfig(RequestConfig.custom().setConnectTimeout((int) context.getTimeout()).build()); request.setConfig(RequestConfig.custom().setSocketTimeout((int) context.getTimeout()).build()); CloseableHttpResponse response; try { response = httpClient.execute(request); } catch (ConnectTimeoutException | SocketTimeoutException e) { throw new TTransportException(TTransportException.TIMED_OUT, "http request timed out"); } catch (IOException e) { System.out.println(e.getClass()); throw new TTransportException("http request failed: " + e.getMessage()); } try { int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_REQUEST_TOO_LONG) { throw FMessageSizeException.response("response was too large for the transport"); } String responseBody = ""; HttpEntity responseEntity = response.getEntity(); if (responseEntity != null) { responseBody = EntityUtils.toString(responseEntity, "utf-8"); } if (status >= 300) { throw new TTransportException("response errored with code " + status + " and message " + responseBody); } return Base64.decodeBase64(responseBody); } catch (IOException e) { throw new TTransportException("could not decodeFromFrame response body: " + e.getMessage()); } finally { try { response.close(); } catch (IOException e) { LOGGER.warn("could not close server response: " + e.getMessage()); } } }

Target:
private byte[] makeRequest(FContext context, byte[] requestPayload) throws TTransportException { String encoded = Base64.encodeBase64String(requestPayload); StringEntity requestEntity = new StringEntity(encoded, ContentType.create("application/x-frugal", "utf-8")); HttpPost request = new HttpPost(url); request.setHeader("accept", "application/x-frugal"); request.setHeader("content-transfer-encoding", "base64"); if (responseSizeLimit > 0) { request.setHeader("x-frugal-payload-limit", Integer.toString(responseSizeLimit)); } request.setEntity(requestEntity); request.setConfig(RequestConfig.custom() .setConnectTimeout((int) context.getTimeout()) .setSocketTimeout((int) context.getTimeout()) .build()); CloseableHttpResponse response; try { response = httpClient.execute(request); } catch (ConnectTimeoutException | SocketTimeoutException e) { throw new TTransportException(TTransportException.TIMED_OUT, "http request timed out: " + e.getMessage()); } catch (IOException e) { throw new TTransportException("http request failed: " + e.getMessage()); } try { int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_REQUEST_TOO_LONG) { throw FMessageSizeException.response("response was too large for the transport"); } String responseBody = ""; HttpEntity responseEntity = response.getEntity(); if (responseEntity != null) { responseBody = EntityUtils.toString(responseEntity, "utf-8"); } if (status >= 300) { throw new TTransportException("response errored with code " + status + " and message " + responseBody); } return Base64.decodeBase64(responseBody); } catch (IOException e) { throw new TTransportException("could not decodeFromFrame response body: " + e.getMessage()); } finally { try { response.close(); } catch (IOException e) { LOGGER.warn("could not close server response: " + e.getMessage()); } } }