Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpPatch


    @Override
    public <T> void patch(Edm edm, String resourcePath, Object data, Olingo2ResponseHandler<T> responseHandler) {
        final UriInfoImpl uriInfo = parseUri(edm, resourcePath, null);

        writeContent(edm, new HttpPatch(createUri(resourcePath, null)), uriInfo, data, responseHandler);
    }
View Full Code Here


            } else if (method.equals(HTTPConstants.DELETE)) {
                httpRequest = new HttpDelete(uri);
            } else if (method.equals(HTTPConstants.GET)) {
                httpRequest = new HttpGet(uri);
            } else if (method.equals(HTTPConstants.PATCH)) {
                httpRequest = new HttpPatch(uri);
            } else {
                throw new IllegalArgumentException("Unexpected method: "+method);
            }
            setupRequest(url, httpRequest, res); // can throw IOException
        } catch (Exception e) {
View Full Code Here

                    entity = newBufferedHttpEntity(entity);
                }
                putMethod.setEntity(entity);
            }
        } else if (request.getHttpMethod() == HttpMethodName.PATCH) {
            HttpPatch patchMethod = new HttpPatch(uri);
            httpRequest = patchMethod;

            /*
             * We should never reuse the entity of the previous request, since
             * reading from the buffered entity will bypass reading from the
             * original request content. And if the content contains InputStream
             * wrappers that were added for validation-purpose (e.g.
             * Md5DigestCalculationInputStream), these wrappers would never be
             * read and updated again after AmazonHttpClient resets it in
             * preparation for the retry. Eventually, these wrappers would
             * return incorrect validation result.
             */
            if (request.getContent() != null) {
                HttpEntity entity = new RepeatableInputStreamRequestEntity(request);
                if (request.getHeaders().get("Content-Length") == null) {
                    entity = newBufferedHttpEntity(entity);
                }
                patchMethod.setEntity(entity);
            }
        } else if (request.getHttpMethod() == HttpMethodName.GET) {
            httpRequest = new HttpGet(uri);
        } else if (request.getHttpMethod() == HttpMethodName.DELETE) {
            httpRequest = new HttpDelete(uri);
View Full Code Here

    HttpRequestBase request =
        httpMethod == ODataHttpMethod.GET ? new HttpGet() :
            httpMethod == ODataHttpMethod.DELETE ? new HttpDelete() :
                httpMethod == ODataHttpMethod.POST ? new HttpPost() :
                    httpMethod == ODataHttpMethod.PUT ? new HttpPut() : new HttpPatch();
    request.setURI(URI.create(getEndpoint() + uri));
    if (additionalHeader != null) {
      request.addHeader(additionalHeader, additionalHeaderValue);
    }
    if (requestBody != null) {
View Full Code Here

    assertTrue(payload.contains("error"));
  }

  @Test
  public void patch() throws Exception {
    HttpPatch get = new HttpPatch(URI.create(getEndpoint().toString() + "aaa/bbb/ccc"));
    final HttpResponse response = getHttpClient().execute(get);

    assertEquals(HttpStatusCodes.NOT_FOUND.getStatusCode(), response.getStatusLine().getStatusCode());
    final String payload = StringHelper.inputStreamToString(response.getEntity().getContent());
    assertTrue(payload.contains("error"));
View Full Code Here

    assertEquals(HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE.getStatusCode(), response.getStatusLine().getStatusCode());
  }

  @Test
  public void unsupportedContentTypeParameter() throws Exception {
    HttpPatch patch = new HttpPatch(URI.create(getEndpoint().toString() + "Rooms('1')"));
    patch.setHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.APPLICATION_JSON + ";illegal=wrong");
    final HttpResponse response = getHttpClient().execute(patch);
    assertEquals(HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE.getStatusCode(), response.getStatusLine().getStatusCode());
  }
View Full Code Here

   */
  @Override
  public <T> T patchEntity ( URL url, Map<String, String> paramMap, Class<T> clazz, Map<String, String> newHeaders )
      throws ParseException, RestException, RuntimeRestException, URISyntaxException
  {
    HttpPatch patch = new HttpPatch(url.toURI());
    setupMethod(patch, newHeaders);
    writeObject(paramMap, patch);
    return readObject(clazz, execute(patch));
  }
View Full Code Here

   * java.util.Map, java.util.Map)
   */
  @Override
  public void patch ( URL url, Map<String, String> paramMap, Map<String, String> newHeaders ) throws ParseException, RestException, RuntimeRestException, URISyntaxException
  {
    HttpPatch patch = new HttpPatch(url.toURI());
    setupMethod(patch, newHeaders);
    writeObject(paramMap, patch);
    HttpResponse response = execute(patch);
    EntityUtils.consumeQuietly(response.getEntity());
  }
View Full Code Here

                } 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);
        }
    }
View Full Code Here

         try {
    DefaultHttpClient httpClient = new DefaultHttpClient();
                httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM),
                new UsernamePasswordCredentials(user, new String(pass)));
    HttpPatch patchRequest = new HttpPatch(url);

    StringEntity input = new StringEntity(data.toString());
    input.setContentType("application/json");
                System.out.println("data: "+data.toString());
    patchRequest.setEntity(input);
    HttpResponse response = httpClient.execute(patchRequest);

    BufferedReader br = new BufferedReader(
                        new InputStreamReader((response.getEntity().getContent())));
View Full Code Here

TOP

Related Classes of org.apache.http.client.methods.HttpPatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.