List of usage examples for org.apache.http.client.methods HttpTrace METHOD_NAME
String METHOD_NAME
To view the source code for org.apache.http.client.methods HttpTrace METHOD_NAME.
Click Source Link
From source file:org.gradle.internal.resource.transport.http.AlwaysRedirectRedirectStrategy.java
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException { URI uri = this.getLocationURI(request, response, context); String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) { return new HttpHead(uri); } else if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) { return this.copyEntity(new HttpPost(uri), request); } else if (method.equalsIgnoreCase(HttpPut.METHOD_NAME)) { return this.copyEntity(new HttpPut(uri), request); } else if (method.equalsIgnoreCase(HttpDelete.METHOD_NAME)) { return new HttpDelete(uri); } else if (method.equalsIgnoreCase(HttpTrace.METHOD_NAME)) { return new HttpTrace(uri); } else if (method.equalsIgnoreCase(HttpOptions.METHOD_NAME)) { return new HttpOptions(uri); } else if (method.equalsIgnoreCase(HttpPatch.METHOD_NAME)) { return this.copyEntity(new HttpPatch(uri), request); } else {/* www . j a v a 2 s . c o m*/ return new HttpGet(uri); } }
From source file:org.camunda.connect.httpclient.HttpRequestTest.java
@Test public void setHttpMethod() { HttpRequest request = connector.createRequest().get(); assertThat(request.getMethod()).isEqualTo(HttpGet.METHOD_NAME); request = connector.createRequest().post(); assertThat(request.getMethod()).isEqualTo(HttpPost.METHOD_NAME); request = connector.createRequest().put(); assertThat(request.getMethod()).isEqualTo(HttpPut.METHOD_NAME); request = connector.createRequest().delete(); assertThat(request.getMethod()).isEqualTo(HttpDelete.METHOD_NAME); request = connector.createRequest().patch(); assertThat(request.getMethod()).isEqualTo(HttpPatch.METHOD_NAME); request = connector.createRequest().head(); assertThat(request.getMethod()).isEqualTo(HttpHead.METHOD_NAME); request = connector.createRequest().options(); assertThat(request.getMethod()).isEqualTo(HttpOptions.METHOD_NAME); request = connector.createRequest().trace(); assertThat(request.getMethod()).isEqualTo(HttpTrace.METHOD_NAME); }
From source file:org.camunda.connect.httpclient.impl.AbstractHttpRequest.java
public Q trace() { return method(HttpTrace.METHOD_NAME); }
From source file:org.camunda.connect.httpclient.impl.AbstractHttpConnector.java
@SuppressWarnings("unchecked") protected <T extends HttpRequestBase> T createHttpRequestBase(Q request) { String url = request.getUrl(); if (url != null && !url.trim().isEmpty()) { String method = request.getMethod(); if (HttpGet.METHOD_NAME.equals(method)) { return (T) new HttpGet(url); } else if (HttpPost.METHOD_NAME.equals(method)) { return (T) new HttpPost(url); } else if (HttpPut.METHOD_NAME.equals(method)) { return (T) new HttpPut(url); } else if (HttpDelete.METHOD_NAME.equals(method)) { return (T) new HttpDelete(url); } else if (HttpPatch.METHOD_NAME.equals(method)) { return (T) new HttpPatch(url); } else if (HttpHead.METHOD_NAME.equals(method)) { return (T) new HttpHead(url); } else if (HttpOptions.METHOD_NAME.equals(method)) { return (T) new HttpOptions(url); } else if (HttpTrace.METHOD_NAME.equals(method)) { return (T) new HttpTrace(url); } else {// ww w . ja v a 2s .co m throw LOG.unknownHttpMethod(method); } } else { throw LOG.requestUrlRequired(); } }
From source file:code.google.restclient.core.Hitter.java
/** * Method to make POST or PUT request by sending http entity (as body) *//*w ww. jav a 2 s. c om*/ public void hit(String url, String methodName, HttpHandler handler, Map<String, String> requestHeaders) throws Exception { if (DEBUG_ENABLED) LOG.debug("hit() - method => " + methodName + ", url => " + url); if (HttpGet.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> GET " + url); hit(url, new HttpGet(url), handler, requestHeaders); } else if (HttpHead.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> HEAD " + url); hit(url, new HttpHead(url), handler, requestHeaders); } else if (HttpDelete.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> DELETE " + url); hit(url, new HttpDelete(url), handler, requestHeaders); } else if (HttpOptions.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> OPTIONS " + url); hit(url, new HttpOptions(url), handler, requestHeaders); } else if (HttpTrace.METHOD_NAME.equals(methodName)) { if (DEBUG_ENABLED) LOG.debug("hit() - ===> TRACE " + url); hit(url, new HttpTrace(url), handler, requestHeaders); } else if (HttpPost.METHOD_NAME.equals(methodName)) { // POST if (DEBUG_ENABLED) LOG.debug("hit() - ===> POST " + url); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(handler.getReqBodyEntity()); hit(url, httpPost, handler, requestHeaders); } else if (HttpPut.METHOD_NAME.equals(methodName)) { // PUT if (DEBUG_ENABLED) LOG.debug("hit() - ===> PUT " + url); HttpPut httpPut = new HttpPut(url); httpPut.setEntity(handler.getReqBodyEntity()); hit(url, httpPut, handler, requestHeaders); } else { throw new IllegalArgumentException("hit(): Unsupported method => " + methodName); } }
From source file:org.jboss.as.test.integration.security.perimeter.WebConsoleSecurityTestCase.java
@Test public void testTrace() throws Exception { getConnection().setRequestMethod(HttpTrace.METHOD_NAME); getConnection().connect();// w ww . ja v a 2 s . co m assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, getConnection().getResponseCode()); }
From source file:org.elasticsearch.client.RestClient.java
private static HttpRequestBase createHttpRequest(String method, URI uri, HttpEntity entity) { switch (method.toUpperCase(Locale.ROOT)) { case HttpDeleteWithEntity.METHOD_NAME: return addRequestBody(new HttpDeleteWithEntity(uri), entity); case HttpGetWithEntity.METHOD_NAME: return addRequestBody(new HttpGetWithEntity(uri), entity); case HttpHead.METHOD_NAME: return addRequestBody(new HttpHead(uri), entity); case HttpOptions.METHOD_NAME: return addRequestBody(new HttpOptions(uri), entity); case HttpPatch.METHOD_NAME: return addRequestBody(new HttpPatch(uri), entity); case HttpPost.METHOD_NAME: HttpPost httpPost = new HttpPost(uri); addRequestBody(httpPost, entity); return httpPost; case HttpPut.METHOD_NAME: return addRequestBody(new HttpPut(uri), entity); case HttpTrace.METHOD_NAME: return addRequestBody(new HttpTrace(uri), entity); default:/* w ww . j a v a 2s . co m*/ throw new UnsupportedOperationException("http method not supported: " + method); } }
From source file:org.apache.nutch.protocol.httpclient.HttpClientRedirectStrategy.java
public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response, final HttpContext context) throws ProtocolException { URI uri = getLocationURI(request, response, context); String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) { return new HttpHead(uri); } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) { return new HttpGet(uri); } else {/*from w ww . j a va2 s . co m*/ int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_TEMPORARY_REDIRECT) { if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) { return copyEntity(new HttpPost(uri), request); } else if (method.equalsIgnoreCase(HttpPut.METHOD_NAME)) { return copyEntity(new HttpPut(uri), request); } else if (method.equalsIgnoreCase(HttpDelete.METHOD_NAME)) { return new HttpDelete(uri); } else if (method.equalsIgnoreCase(HttpTrace.METHOD_NAME)) { return new HttpTrace(uri); } else if (method.equalsIgnoreCase(HttpOptions.METHOD_NAME)) { return new HttpOptions(uri); } else if (method.equalsIgnoreCase(HttpPatch.METHOD_NAME)) { return copyEntity(new HttpPatch(uri), request); } } return new HttpGet(uri); } }