public HttpInputStream get(String url, boolean failIfNotOK, String user, String pass) throws IOException { return get(url, failIfNotOK, user, pass, null, null, null); }
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, String user, String pass) throws IOException { return get(url, failIfNotOK, user, pass, null, null, null); }
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, String user, String pass, String ifNoneMatch, String ifModifiedSince, String range) throws IOException { UsernamePasswordCredentials creds = null; if (user != null && !user.isEmpty() && pass != null && !pass.isEmpty()) creds = new UsernamePasswordCredentials(user, pass); return get(url, failIfNotOK, creds, ifNoneMatch, ifModifiedSince, range); }
public HttpInputStream get(String url, boolean failIfNotOK, String user, String pass, String ifNoneMatch, String ifModifiedSince, String range) throws IOException { UsernamePasswordCredentials creds = null; if (user != null && !user.isEmpty() && pass != null && !pass.isEmpty()) creds = new UsernamePasswordCredentials(user, pass); return get(url, failIfNotOK, creds, ifNoneMatch, ifModifiedSince, range); }
/** * 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 InputStream getServerResponseAsStream(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.get(url, true, creds); }
/** * 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 InputStream getServerResponseAsStream(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.get(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); }
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); }
/** * Performs the given HTTP request, logging a warning if we don't get a 200 * OK response. */ private void sendRESTMessage(String url) { HttpInputStream response = null; try { logger.debug("Getting " + url); response = _webClient.get(url, false, _gSearchCredentials); int code = response.getStatusCode(); if (code != 200) { logger.warn("Error sending update to GSearch service (url=" + url + "). HTTP response code was " + code + ". " + "Body of response from GSearch follows:\n" + getString(response)); } } catch (Exception e) { logger.warn("Error sending update to GSearch service via URL: " + url, e); } finally { if (response != null) { try { response.close(); } catch (Exception e) { logger.warn("Error closing GSearch response", e); } } } }
/** * Performs the given HTTP request, logging a warning if we don't get a 200 * OK response. */ private void sendRESTMessage(String url) { HttpInputStream response = null; try { logger.debug("Getting " + url); response = _webClient.get(url, false, _gSearchCredentials); int code = response.getStatusCode(); if (code != 200) { logger.warn("Error sending update to GSearch service (url=" + url + "). HTTP response code was " + code + ". " + "Body of response from GSearch follows:\n" + getString(response)); } } catch (Exception e) { logger.warn("Error sending update to GSearch service via URL: " + url, e); } finally { if (response != null) { try { response.close(); } catch (Exception e) { logger.warn("Error closing GSearch response", e); } } } }
@Test public void testDefaultToGetMethod() throws HttpServiceNotFoundException, GeneralException, IOException, RangeNotSatisfiableException { mockResponseFor(null); when(mockClient.get(TEST_URL, true, null, null, null, null, null)) .thenReturn(mockResponse); testObj.getExternalContent(mockParams); verify(mockClient).get(TEST_URL, true, null, null, null, null, null); }
@Test public void testConditionalGetETagMethod() throws HttpServiceNotFoundException, GeneralException, IOException, RangeNotSatisfiableException { mockResponseFor("GET"); when(mockClient.get(TEST_URL, true, null, null, "LOL", null, null)) .thenReturn(mockResponse); when(mockContext.getHeaderValue(HttpHeaders.IF_NONE_MATCH)).thenReturn("LOL"); testObj.getExternalContent(mockParams); verify(mockClient).get(TEST_URL, true, null, null, "LOL", null, null); }
@Test public void testConditionalGetRangeMethod() throws HttpServiceNotFoundException, GeneralException, IOException, RangeNotSatisfiableException { mockResponseFor("GET"); when(mockClient.get(TEST_URL, true, null, null, null, null, "LOL")) .thenReturn(mockResponse); when(mockContext.getHeaderValue(HttpHeaders.RANGE)).thenReturn("LOL"); testObj.getExternalContent(mockParams); verify(mockClient).get(TEST_URL, true, null, null, null, null, "LOL"); }
@Test public void testConditionalGetDateMethod() throws HttpServiceNotFoundException, GeneralException, IOException, RangeNotSatisfiableException { mockResponseFor("GET"); when(mockClient.get(TEST_URL, true, null, null, null, "LOL", null)) .thenReturn(mockResponse); when(mockContext.getHeaderValue(HttpHeaders.IF_MODIFIED_SINCE)).thenReturn("LOL"); testObj.getExternalContent(mockParams); verify(mockClient).get(TEST_URL, true, null, null, null, "LOL", null); }
WebClientConfiguration webconfig = m_server.getWebClientConfig(); WebClient webClient = new WebClient(webconfig); is = webClient.get(dsLocation, true); } catch (IOException ioe) { throw new Exception("Could not retrive content from "
WebClientConfiguration webconfig = m_server.getWebClientConfig(); WebClient webClient = new WebClient(webconfig); is = webClient.get(dsLocation, true); } catch (IOException ioe) { throw new Exception("Could not retrive content from "
context.getHeaderValue("Range")); } else { response = m_http.get( url, true, user, pass, context.getHeaderValue(HttpHeaders.IF_NONE_MATCH),
context.getHeaderValue("Range")); } else { response = m_http.get( url, true, user, pass, context.getHeaderValue(HttpHeaders.IF_NONE_MATCH),