List of usage examples for org.apache.http.client.methods HttpPatch METHOD_NAME
String METHOD_NAME
To view the source code for org.apache.http.client.methods HttpPatch METHOD_NAME.
Click Source Link
From source file:com.wudaosoft.net.httpclient.ParameterRequestBuilder.java
public static HttpUriRequest build(RequestBuilder builder) { final HttpRequestBase result; URI uriNotNull = builder.getUri() != null ? builder.getUri() : URI.create("/"); Charset charset = builder.getCharset(); charset = charset != null ? charset : HTTP.DEF_CONTENT_CHARSET; String method = builder.getMethod(); List<NameValuePair> parameters = builder.getParameters(); HttpEntity entityCopy = builder.getEntity(); if (parameters != null && !parameters.isEmpty()) { if (entityCopy == null && (HttpPost.METHOD_NAME.equalsIgnoreCase(method) || HttpPut.METHOD_NAME.equalsIgnoreCase(method) || HttpPatch.METHOD_NAME.equalsIgnoreCase(method))) { entityCopy = new UrlEncodedFormEntity(parameters, charset); } else {//ww w . ja v a 2 s .c o m try { uriNotNull = new URIBuilder(uriNotNull).setCharset(charset).addParameters(parameters).build(); } catch (final URISyntaxException ex) { // should never happen } } } if (entityCopy == null) { result = new InternalRequest(method); } else { final InternalEntityEclosingRequest request = new InternalEntityEclosingRequest(method); request.setEntity(entityCopy); result = request; } result.setProtocolVersion(builder.getVersion()); result.setURI(uriNotNull); // if (builder.headergroup != null) { // result.setHeaders(builder.headergroup.getAllHeaders()); // } result.setConfig(builder.getConfig()); return result; }
From source file:org.fcrepo.camel.HttpMethodsTest.java
@Test public void testMethods() { assertEquals(HttpMethods.DELETE.toString(), HttpDelete.METHOD_NAME); assertEquals(HttpMethods.GET.toString(), HttpGet.METHOD_NAME); assertEquals(HttpMethods.HEAD.toString(), HttpHead.METHOD_NAME); assertEquals(HttpMethods.OPTIONS.toString(), HttpOptions.METHOD_NAME); assertEquals(HttpMethods.PATCH.toString(), HttpPatch.METHOD_NAME); assertEquals(HttpMethods.POST.toString(), HttpPost.METHOD_NAME); assertEquals(HttpMethods.PUT.toString(), HttpPut.METHOD_NAME); }
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 {/*w w w . j a v a 2 s. c om*/ return new HttpGet(uri); } }
From source file:com.clickntap.vimeo.Vimeo.java
public VimeoResponse updateVideoMetadata(String videoEndpoint, String name, String description, String license, String privacyView, String privacyEmbed, Boolean reviewLink) throws IOException { Map<String, String> params = new HashMap<String, String>(); if (name != null) params.put("name", name); if (description != null) params.put("description", description); if (license != null) params.put("license", license); if (privacyView != null) params.put("privacy.view", privacyView); if (privacyEmbed != null) params.put("privacy.embed", privacyEmbed); if (reviewLink != null) params.put("review_link", reviewLink ? "true" : "false"); return apiRequest(videoEndpoint, HttpPatch.METHOD_NAME, params, null); }
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:com.uploader.Vimeo.java
public VimeoResponse updateVideoMetadata(String videoEndpoint, String name, String description, String license, String privacyView, String privacyEmbed, boolean reviewLink) throws IOException { Map<String, String> params = new HashMap<String, String>(); params.put("name", name); params.put("description", description); params.put("license", license); params.put("privacy.view", privacyView); params.put("privacy.embed", privacyEmbed); params.put("review_link", reviewLink ? "true" : "false"); System.out.println(params);/* w w w . java 2 s . c om*/ return apiRequest(videoEndpoint, HttpPatch.METHOD_NAME, params, null); }
From source file:com.wudaosoft.net.httpclient.SortHeadersInterceptor.java
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { if (!request.containsHeader("Accept")) { request.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); }//from ww w .j ava2 s.c o m if (!request.containsHeader("Content-Type")) { request.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); } // request.addHeader("Accept-Language", "zh-CN,zh;q=0.8,ja;q=0.6,en;q=0.4"); request.addHeader("Cache-Control", "no-cache"); request.addHeader("Pragma", "no-cache"); if (request.containsHeader("X-Requested-With")) { String method = ((HttpUriRequest) request).getMethod(); if (HttpPost.METHOD_NAME.equals(method) || HttpPut.METHOD_NAME.equals(method) || HttpPatch.METHOD_NAME.equals(method)) { // request.setHeader("Accept", "application/json, text/javascript, */*; q=0.01"); request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); } request.addHeader("Origin", hostConfig.getHostUrl()); } if (!request.containsHeader("Referer") && hostConfig.getReferer() != null) { request.addHeader("Referer", hostConfig.getReferer()); } request.setHeader("User-Agent", hostConfig.getUserAgent() != null ? hostConfig.getUserAgent() : userAgent); copyAndSet(sortKeyList, request); }
From source file:org.camunda.connect.httpclient.impl.AbstractHttpRequest.java
public Q patch() { return method(HttpPatch.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 {//www .ja v a 2s . c o m throw LOG.unknownHttpMethod(method); } } else { throw LOG.requestUrlRequired(); } }