public HttpInputStream get(String url, boolean failIfNotOK, String user, String pass) throws IOException { return get(url, failIfNotOK, user, pass, null, null, null); }
public HttpInputStream head(String url, boolean failIfNotOK, String user, String pass) throws IOException { return head(url, failIfNotOK, user, pass, null, null, null); }
/** * Hits the given Fedora Server URL and returns the response as a String. * Throws an IOException if the response code is not 200(OK). */ private static String getServerResponse(String protocol, String user, String pass, String path) throws IOException { String url = getBaseURL(protocol) + path; logger.info("Getting URL: {}", url); UsernamePasswordCredentials creds = new UsernamePasswordCredentials(user, pass); return s_webClient.getResponseAsString(url, true, creds); }
public HttpInputStream get(String url, boolean failIfNotOK, UsernamePasswordCredentials creds, String ifNoneMatch, String ifModifiedSince, String range) throws IOException { return execute(new HttpGet(url), url, failIfNotOK, creds, ifNoneMatch, ifModifiedSince, range); }
try { if (headOnly) { response = m_http.head(url, true, user, pass, context.getHeaderValue(HttpHeaders.IF_NONE_MATCH), context.getHeaderValue(HttpHeaders.IF_MODIFIED_SINCE), context.getHeaderValue("Range")); } else { response = m_http.get( url, true, user, pass, context.getHeaderValue(HttpHeaders.IF_NONE_MATCH),
public String getResponseAsString(String url, boolean failIfNotOK, UsernamePasswordCredentials creds) throws IOException { InputStream in = get(url, failIfNotOK, creds); // Convert the response into a String. try { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuffer buffer = new StringBuffer(); String line = reader.readLine(); while (line != null) { buffer.append(line + "\n"); line = reader.readLine(); } return buffer.toString(); } finally { try { in.close(); } catch (Exception e) { logger.error("Can't close InputStream: " + e.getMessage()); } } }
public WebClient(WebClientConfiguration webconfig, ProxyConfiguration proxyconfig){ wconfig = webconfig; proxy = proxyconfig; cManager = configureConnectionManager(wconfig); }
HttpClient client; setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); if (creds != null && creds.getUserName() != null && creds.getUserName().length() > 0) { client = getHttpClient(url, creds); } else { client = getHttpClient(url); setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); in = new HttpInputStream(client, request); status = in.getStatusCode();
private static WebClient getWebClient() { WebClientConfiguration webconfig = new WebClientConfiguration(); initWebClientConfig(webconfig); return new WebClient(webconfig); }
public HttpInputStream head(String url, boolean failIfNotOK, UsernamePasswordCredentials creds, String ifNoneMatch, String ifModifiedSince, String range) throws IOException { return execute(new HttpHead(url), url, failIfNotOK, creds, ifNoneMatch, ifModifiedSince, range); }
public HttpClient getHttpClient(String hostOrURL, UsernamePasswordCredentials creds) throws IOException, ConnectTimeoutException { String host = null; if (hostOrURL != null) { if (hostOrURL.indexOf("/") != -1) { URL url = new URL(hostOrURL); host = url.getHost(); } else { host = hostOrURL; } } DefaultHttpClient client; if (host != null && creds != null) { client = new PreemptiveAuth(cManager); client.getCredentialsProvider().setCredentials(new AuthScope(host, AuthScope.ANY_PORT), creds); } else { client = new DefaultHttpClient(cManager); } client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, wconfig.getTimeoutSecs() * 1000); client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, wconfig.getSockTimeoutSecs() * 1000); if (proxy.isHostProxyable(host)) { HttpHost proxyHost = new HttpHost(proxy.getProxyHost(), proxy.getProxyPort(), "http");
try { if (headOnly) { response = m_http.head(url, true, user, pass, context.getHeaderValue(HttpHeaders.IF_NONE_MATCH), context.getHeaderValue(HttpHeaders.IF_MODIFIED_SINCE), context.getHeaderValue("Range")); } else { response = m_http.get( url, true, user, pass, context.getHeaderValue(HttpHeaders.IF_NONE_MATCH),
public String getResponseAsString(String url, boolean failIfNotOK, UsernamePasswordCredentials creds) throws IOException { InputStream in = get(url, failIfNotOK, creds); // Convert the response into a String. try { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuffer buffer = new StringBuffer(); String line = reader.readLine(); while (line != null) { buffer.append(line + "\n"); line = reader.readLine(); } return buffer.toString(); } finally { try { in.close(); } catch (Exception e) { logger.error("Can't close InputStream: " + e.getMessage()); } } }
public HttpInputStream get(String url, boolean failIfNotOK, UsernamePasswordCredentials creds, String ifNoneMatch, String ifModifiedSince, String range) throws IOException { return execute(new HttpGet(url), url, failIfNotOK, creds, ifNoneMatch, ifModifiedSince, range); }
public WebClient(WebClientConfiguration webconfig, ProxyConfiguration proxyconfig){ wconfig = webconfig; proxy = proxyconfig; cManager = configureConnectionManager(wconfig); }
HttpClient client; setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); if (creds != null && creds.getUserName() != null && creds.getUserName().length() > 0) { client = getHttpClient(url, creds); } else { client = getHttpClient(url); setHeaders(request, wconfig.getUserAgent(), ifNoneMatch, ifModifiedSince, range); in = new HttpInputStream(client, request); status = in.getStatusCode();
private static WebClient getWebClient() { WebClientConfiguration webconfig = new WebClientConfiguration(); initWebClientConfig(webconfig); return new WebClient(webconfig); }
public HttpInputStream head(String url, boolean failIfNotOK, UsernamePasswordCredentials creds, String ifNoneMatch, String ifModifiedSince, String range) throws IOException { return execute(new HttpHead(url), url, failIfNotOK, creds, ifNoneMatch, ifModifiedSince, range); }