001/**
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 *
006 */
007package org.fcrepo.migration.foxml;
008
009import java.io.IOException;
010import java.io.InputStream;
011import java.net.URL;
012
013import org.apache.http.client.methods.HttpGet;
014import org.apache.http.impl.client.CloseableHttpClient;
015import org.apache.http.impl.client.HttpClients;
016/**
017 *
018 * @author mdurbin
019 *
020 */
021public class HttpClientURLFetcher implements URLFetcher {
022
023    CloseableHttpClient httpClient;
024
025    /**
026     * Http Client URL fetcher.
027     */
028    public HttpClientURLFetcher() {
029        httpClient = HttpClients.createDefault();
030    }
031
032    @Override
033    public InputStream getContentAtUrl(final URL url) throws IOException {
034        return httpClient.execute(new HttpGet(String.valueOf(url))).getEntity().getContent();
035
036    }
037}