StringBuffer buffer = new StringBuffer(method.getPath()); String query = method.getQueryString(); if (query != null) {
this.conn.getHost(), this.conn.getPort(), method.getPath() );
/** * @param httpClient * @param httpMethod * @return * Returns the HTTP Status Code or -1 if an exception occurred. */ public static int executeMethod(HttpClient httpClient, HttpMethod httpMethod) { // Execute GetMethod try { return httpClient.executeMethod(httpMethod); } catch (IOException e) { LOGGER.warn("Exception while executing HttpMethod " + httpMethod.getName() + " on URL " + httpMethod.getPath()); return -1; } }
/** * @param httpClient * @param httpMethod * @return Returns the HTTP Status Code or -1 if an exception occurred. */ public static int executeMethod(final HttpClient httpClient, final HttpMethod httpMethod) { // Execute GetMethod try { return httpClient.executeMethod(httpMethod); } catch (final IOException e) { LOGGER.warn("Exception while executing HttpMethod " + httpMethod.getName() + " on URL " + httpMethod.getPath()); return -1; } }
void discardResponse(HttpMethod httpMethod) throws IOException { if (log.isDebugEnabled()) { log.debug("Received non-OK response when invoking method on path " + httpMethod.getPath() + ". Response was:\n" + httpMethod.getResponseBodyAsString()); } else { byte[] buf = localBuffer.get(); InputStream responseStream = httpMethod.getResponseBodyAsStream(); while (responseStream.read(buf) != -1); } }
/** * Generate and add the If header to the specified HTTP method. */ protected void generateIfHeader(HttpMethod method) { if (client == null) return; if (method == null) return; WebdavState state = (WebdavState) client.getState(); String[] lockTokens = state.getAllLocks(method.getPath()); if (lockTokens.length == 0) return; StringBuffer ifHeaderValue = new StringBuffer(); for (int i = 0; i < lockTokens.length; i++) { ifHeaderValue.append("(<").append(lockTokens[i]).append(">) "); } method.setRequestHeader("If", ifHeaderValue.toString()); }
/** * {@inheritDoc} */ @Override public void setRequestAuthentication(HttpMethod method, byte[] message) throws IOException { long requestTimestamp = System.currentTimeMillis(); // add MAC header byte[] mac = macUtils.generateMAC(KeyProvider.ALIAS_SOLR, new MACInput(message, requestTimestamp, getLocalIPAddress())); if(logger.isDebugEnabled()) { logger.debug("Setting MAC " + Arrays.toString(mac) + " on HTTP request " + method.getPath()); logger.debug("Setting timestamp " + requestTimestamp + " on HTTP request " + method.getPath()); } setRequestMac(method, mac); // prevent replays setRequestTimestamp(method, requestTimestamp); }
/** * {@inheritDoc} */ @Override public void setRequestAuthentication(HttpMethod method, byte[] message) throws IOException { long requestTimestamp = System.currentTimeMillis(); // add MAC header byte[] mac = macUtils.generateMAC(KeyProvider.ALIAS_SOLR, new MACInput(message, requestTimestamp, getLocalIPAddress())); if(logger.isDebugEnabled()) { logger.debug("Setting MAC " + Arrays.toString(mac) + " on HTTP request " + method.getPath()); logger.debug("Setting timestamp " + requestTimestamp + " on HTTP request " + method.getPath()); } setRequestMac(method, mac); // prevent replays setRequestTimestamp(method, requestTimestamp); }
public InputStream sendData(RestRequest request) throws RestException, IOException { if (!open) { throw new IllegalStateException("the session is not opened"); } HttpMethod gm = doRequest(request); StatusLine sl = gm.getStatusLine(); int statusCode = sl.getStatusCode(); if (log.isDebugEnabled()) { log.debug("status code " + statusCode + " for " + gm.getPath()); } if (statusCode != HttpStatus.SC_OK) { log.error(gm.getResponseBodyAsString()); releaseConnection(getConnection()); throw new RestException( "Got error code <" + statusCode + ":" + sl.getReasonPhrase() + "> on " + gm.getPath()); } InputStream stream = gm.getResponseBodyAsStream(); return stream; }
message.append(method.getPath());
protected String getAbsoluteUri(HttpMethod method, String path) throws URIException { URI uri = method.getURI(); if (path != null) { // reset query string uri.setQuery(null); if (path.startsWith("/")) { // path is absolute, replace method path uri.setPath(path); } else if (path.startsWith("http://") || path.startsWith("https://")) { return path; } else { // relative path, build new path String currentPath = method.getPath(); int end = currentPath.lastIndexOf('/'); if (end >= 0) { uri.setPath(currentPath.substring(0, end + 1) + path); } else { throw new URIException(uri.getURI()); } } } return uri.getURI(); }
/** * Look for session cookies. * * @return true if session cookies are available */ protected boolean isAuthenticated(HttpMethod method) { boolean authenticated = false; if (method.getStatusCode() == HttpStatus.SC_OK && "/ews/services.wsdl".equalsIgnoreCase(method.getPath())) { // direct EWS access returned wsdl authenticated = true; } else { // check cookies for (Cookie cookie : httpClient.getState().getCookies()) { // Exchange 2003 cookies if (cookie.getName().startsWith("cadata") || "sessionid".equals(cookie.getName()) // Exchange 2007 cookie || "UserContext".equals(cookie.getName()) // Direct EWS access || "exchangecookie".equals(cookie.getName()) ) { authenticated = true; break; } } } return authenticated; }
public InputStream askData(RestRequest request) throws RestException, IOException { if (!open) { throw new IllegalStateException("the session is not opened"); } HttpMethod gm; gm = doRequest(request); StatusLine sl = gm.getStatusLine(); int statusCode = sl.getStatusCode(); if (log.isDebugEnabled()) { log.debug("status code " + statusCode + " for " + gm.getPath()); } if (statusCode == HttpStatus.SC_NOT_FOUND) { throw new RestDataNotFoundException( "could not retreave some datas : " + gm.getResponseBodyAsString()); } if (statusCode != HttpStatus.SC_OK) { log.error("Error = " + gm.getResponseBodyAsString()); releaseConnection(getConnection()); throw new RestException( "Got error code <" + statusCode + ":" + sl.getReasonPhrase() + "> on " + gm.getPath()); } InputStream stream = gm.getResponseBodyAsStream(); return stream; }
StringBuffer buffer = new StringBuffer(method.getPath()); String query = method.getQueryString(); if (query != null) {
/** * Test create target. * * @throws Exception */ public void testSuccessfulVerifyTargetOverHttp() throws Exception { //Stub HttpClient so that executeMethod returns a 200 response when(mockedHttpClient.executeMethod(any(HostConfiguration.class), any(HttpMethod.class), any(HttpState.class))).thenReturn(200); //Call verifyTarget transmitter.verifyTarget(target); ArgumentCaptor<HostConfiguration> hostConfig = ArgumentCaptor.forClass(HostConfiguration.class); ArgumentCaptor<HttpMethod> httpMethod = ArgumentCaptor.forClass(HttpMethod.class); ArgumentCaptor<HttpState> httpState = ArgumentCaptor.forClass(HttpState.class); verify(mockedHttpClient).executeMethod(hostConfig.capture(), httpMethod.capture(), httpState.capture()); assertTrue("post method", httpMethod.getValue() instanceof PostMethod); assertEquals("host name", TARGET_HOST, hostConfig.getValue().getHost()); assertEquals("port", HTTP_PORT, hostConfig.getValue().getPort()); assertEquals("protocol", HTTP_PROTOCOL.toLowerCase(), hostConfig.getValue().getProtocol().getScheme().toLowerCase()); assertEquals("path", TRANSFER_SERVICE_PATH + "/test", httpMethod.getValue().getPath()); }
public static URI newURI(HttpMethod m, HostConfiguration conf) throws URIException { String scheme = conf.getProtocol().getScheme(); String host = conf.getHost(); int port = conf.getPort(); return new URIBuilder().getURI(scheme, host, port, m.getPath(), m.getQueryString(), m.getParams()); } }
this.m_httpMethod.getPath() + " " + e.getReason(), e); final int reasonCode = e.getReasonCode(); final String status;
method.getName() + " " + method.getPath());
if (logonMethod != null && "/owa/languageselection.aspx".equals(logonMethod.getPath())) {