Package org.apache.http.client.methods

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


    headers.add(new BasicHeader("Connection", "Close"));
    HttpParams params = new BasicHttpParams();
    params.setParameter("http.default-headers", headers);

    HttpClient httpclient = new DefaultHttpClient(params);
    HttpPut httpput = new HttpPut("http://localhost:" + PORT + "/put");
    HttpResponse response = httpclient.execute(httpput);

    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
View Full Code Here


        try {
            URI uri = url.toURI();
            if (method.equals(POST)) {
                httpRequest = new HttpPost(uri);
            } else if (method.equals(PUT)) {
                httpRequest = new HttpPut(uri);
            } else if (method.equals(HEAD)) {
                httpRequest = new HttpHead(uri);
            } else if (method.equals(TRACE)) {
                httpRequest = new HttpTrace(uri);
            } else if (method.equals(OPTIONS)) {
View Full Code Here

        if(createFolders) {
            mkdirs(getParentPath(path));
        }
        executor.execute(
        builder.buildOtherRequest(
            new HttpPut(builder.buildUrl(path))).withEntity(e)
            .withCredentials(username, password)
        )
        .assertStatus(201);
    }
View Full Code Here

  private static Map<String, Object> putJSON(String url, String body, Integer connectionTimeout, Integer soTimeout)
  {
    Map<String, Object> map;
    try
    {
      HttpPut httpput = new HttpPut(url);
      if (body != null)
      {
        httpput.setHeader("Content-Type", "application/json;charset=UTF-8");
        httpput.setEntity(new StringEntity(body, "UTF-8"));
      }
      map = executeMethod(httpput, url, body, connectionTimeout, soTimeout);
    }
    catch (UnsupportedEncodingException e)
    {
View Full Code Here

  private static Map<String, Object> putJSON(String url, String body, Integer connectionTimeout, Integer soTimeout)
  {
    Map<String, Object> map;
    try
    {
      HttpPut httpput = new HttpPut(url);
      if (body != null)
      {
        httpput.setHeader("Content-Type", "application/json;charset=UTF-8");
        httpput.setEntity(new StringEntity(body, "UTF-8"));
      }
      map = executeMethod(httpput, url, body, connectionTimeout, soTimeout);
    }
    catch (UnsupportedEncodingException e)
    {
View Full Code Here

  public static Map<String, Object> put(String url, String body, Integer connectionTimeout, Integer soTimeout)
  {
    Map<String, Object> map;
    try
    {
      HttpPut httpput = new HttpPut(url);
      if (body != null)
      {
        httpput.setHeader("Content-Type", "application/json;charset=UTF-8");
        httpput.setEntity(new StringEntity(body, "UTF-8"));
      }
      map = executeMethod(httpput, url, body, connectionTimeout, soTimeout);
    }
    catch (UnsupportedEncodingException e)
    {
View Full Code Here

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

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

        }
    }
   
    @Test
    public void testPutConsumer() throws Exception {
        HttpPut put = new HttpPut("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers");
        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        put.setEntity(entity);
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();

        try {
            HttpResponse response = httpclient.execute(put);
            assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

        HttpClient httpClient = new DefaultHttpClient();
        SSLSocketFactory sf = (SSLSocketFactory)httpClient.getConnectionManager()
                .getSchemeRegistry().getScheme("https").getSocketFactory();
        sf.setHostnameVerifier(new AllowAllHostnameVerifier());

        HttpPut request = new HttpPut(Application.baseRestUrl + "/communities/" + this.id);
        request.setHeader("Accept", "application/json");
        request.addHeader("Content-Type", "application/json");
        request.addHeader("rest-dspace-token", token);

        //Only allow certain attributes... "name", "copyrightText", "introductoryText", "shortDescription", "sidebarText"
        Logger.info("EditCommunity json: " + Json.toJson(this).toString());
        ObjectNode jsonObjectNode = Json.newObject().put("name", this.name).put("copyrightText", this.copyrightText)
                .put("introductoryText", this.introductoryText)
                .put("shortDescription", this.shortDescription)
                .put("sidebarText", this.sidebarText);
        StringEntity stringEntity = new StringEntity(jsonObjectNode.toString());
        Logger.info("EditCommunity certain attributes: " + jsonObjectNode.toString());

        request.setEntity(stringEntity);
        HttpResponse httpResponse = httpClient.execute(request);
        RestResponse restResponse = new RestResponse();
        restResponse.httpResponse = httpResponse;
        restResponse.endpoint = request.getURI().toString();
        return restResponse;
    }
View Full Code Here

        httpDelete.setHeader("Accept", acceptType);
        return httpDelete;
      }

      if (requestMethod.equals("PUT")) {
        HttpPut httpPut = new HttpPut(uri);
        httpPut.setHeader("Accept", acceptType);
        httpPut.setEntity(new StringEntity(body));
        return httpPut;
      }

      if (requestMethod.equals("HEAD")) {
        return new HttpHead(uri);
View Full Code Here

TOP

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

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.