class HttpSchemeStrategy implements SchemeStrategy {

    @Override
    public InputStream getInputStream(final String sessionId, final URI uri,
            final RequestMethod method, final long timeout,
            final Collection<KeyValuePair> parameters) throws BadFetchError {
        final HttpClientBuilder builder = SESSION_STORAGE
                .getSessionIdentifier(sessionId);
        final RequestConfig config = setTimeout(timeout);
        try (CloseableHttpClient client = builder
                .setDefaultRequestConfig(config).build()) {
            final String fragmentLessUriString = StringUtils.substringBeforeLast(uri.toString(), "#");
            final URI fragmentLessUri = new URI(fragmentLessUriString);
            final URI requestUri = addParameters(parameters, fragmentLessUri);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("connecting to '" + requestUri + "'...");
            }
            final HttpUriRequest request;
            if (method == RequestMethod.GET) {
                request = new HttpGet(requestUri);
            } else {
                request = new HttpPost(requestUri);
            }
            attachFiles(request, parameters);
            final HttpResponse response = client.execute(request);
            final StatusLine statusLine = response.getStatusLine();
            final int status = statusLine.getStatusCode();
            if (status != HttpStatus.SC_OK) {
                final String reasonPhrase = statusLine.getReasonPhrase();
                LOGGER.error("error accessing '" + uri + "': " + reasonPhrase
                        + " (HTTP error code " + status + ")");
                return null;
            }
            final HttpEntity entity = response.getEntity();
            final InputStream input = entity.getContent();
            final ReadBuffer buffer = new ReadBuffer();
            buffer.read(input);
            return buffer.getInputStream();
        } catch (IOException | URISyntaxException | ParseException
                | SemanticError e) {
            throw new BadFetchError(e.getMessage(), e);
        }
    }

    public  HttpSchemeStrategy();

}