protected <T> T baseHandleResponse(HttpRequestBase request, HttpResponse response, HttpEntity entity, EntityParser<T> entityParser) throws ParseException, IOException { return handleErrorCode(request, response, () -> { try { return entityParser.parse(entity); } catch (IOException e) { throw new ClientIOException(request, e); } }); }
protected <T> T baseHandleResponse(HttpRequestBase request, HttpResponse response, HttpEntity entity, EntityParser<T> entityParser) throws ParseException, IOException { return handleErrorCode(request, response, () -> { try { return entityParser.parse(entity); } catch (IOException e) { throw new ClientIOException(request, e); } }); }
@Override public Document download(String path, Object... parameters) { HttpGet get = new HttpGet(getUrl(path)); return request(get, (request, response, entity) -> { return handleErrorCode(request, response, () -> { // Gets the content as bytes byte[] bytes; try { bytes = EntityUtils.toByteArray(entity); } catch (IOException e) { throw new ClientIOException(request, e); } if (bytes == null || bytes.length == 0) { return Document.EMPTY; } // OK return new Document( entity.getContentType().getValue(), bytes ); }); }); }
@Override public Document download(String path, Object... parameters) { HttpGet get = new HttpGet(getUrl(path)); return request(get, (request, response, entity) -> { return handleErrorCode(request, response, () -> { // Gets the content as bytes byte[] bytes; try { bytes = EntityUtils.toByteArray(entity); } catch (IOException e) { throw new ClientIOException(request, e); } if (bytes == null || bytes.length == 0) { return Document.EMPTY; } // OK return new Document( entity.getContentType().getValue(), bytes ); }); }); }