Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpPut.addHeader()


        // Content-Length: nnn
        // ...binary data...
        HttpPut put = new HttpPut(providerURI + "/" + mediaId);
        put.addHeader("Content-Type", "image/jpg");
        put.addHeader("Title", "Title " + receiptName + "");
        put.addHeader("Slug", "Slug " + receiptName + "");
        put.setEntity(new FileEntity(input, "image/jpg"));

        // Get HTTP client
        HttpClient httpclient = new HttpClientFactory().createHttpClient();
        try {
View Full Code Here


        // Host: media.example.org
        // Content-Type: image/png
        // Content-Length: nnn
        // ...binary data...
        HttpPut put = new HttpPut(providerURI + "/" + mediaId + "-bogus"); // Does not exist.
        put.addHeader("Content-Type", "image/jpg");
        put.addHeader("Title", "Title " + receiptName + "");
        put.addHeader("Slug", "Slug " + receiptName + "");
        put.setEntity(new FileEntity(input, "image/jpg"));

        // Get HTTP client
View Full Code Here

        // Content-Type: image/png
        // Content-Length: nnn
        // ...binary data...
        HttpPut put = new HttpPut(providerURI + "/" + mediaId + "-bogus"); // Does not exist.
        put.addHeader("Content-Type", "image/jpg");
        put.addHeader("Title", "Title " + receiptName + "");
        put.addHeader("Slug", "Slug " + receiptName + "");
        put.setEntity(new FileEntity(input, "image/jpg"));

        // Get HTTP client
        HttpClient httpclient = new HttpClientFactory().createHttpClient();
View Full Code Here

        // Content-Length: nnn
        // ...binary data...
        HttpPut put = new HttpPut(providerURI + "/" + mediaId + "-bogus"); // Does not exist.
        put.addHeader("Content-Type", "image/jpg");
        put.addHeader("Title", "Title " + receiptName + "");
        put.addHeader("Slug", "Slug " + receiptName + "");
        put.setEntity(new FileEntity(input, "image/jpg"));

        // Get HTTP client
        HttpClient httpclient = new HttpClientFactory().createHttpClient();
        try {
View Full Code Here

  {
    HttpPut put = new HttpPut(url);
    put.setEntity(entity);
    for (Header header : headers)
    {
      put.addHeader(header);
    }
    if (entity.getContentType() == null && !put.containsHeader(HttpHeaders.CONTENT_TYPE))
    {
      put.addHeader(HttpHeaders.CONTENT_TYPE, HTTP.DEF_CONTENT_CHARSET.name());
    }
View Full Code Here

    {
      put.addHeader(header);
    }
    if (entity.getContentType() == null && !put.containsHeader(HttpHeaders.CONTENT_TYPE))
    {
      put.addHeader(HttpHeaders.CONTENT_TYPE, HTTP.DEF_CONTENT_CHARSET.name());
    }
    try
    {
      return this.execute(put, handler);
    }
View Full Code Here

    public void testUpdateCustomerBodyAndHeaders() throws Exception {
        HttpPut put = new HttpPut("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123");
        StringWriter sw = new StringWriter();
        jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
        put.setEntity(new StringEntity(sw.toString()));
        put.addHeader("Content-Type", "text/xml");
        put.addHeader("Accept", "text/xml");
        HttpResponse response = httpclient.execute(put);
        assertEquals(200, response.getStatusLine().getStatusCode());
    }
   
View Full Code Here

        HttpPut put = new HttpPut("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/123");
        StringWriter sw = new StringWriter();
        jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
        put.setEntity(new StringEntity(sw.toString()));
        put.addHeader("Content-Type", "text/xml");
        put.addHeader("Accept", "text/xml");
        HttpResponse response = httpclient.execute(put);
        assertEquals(200, response.getStatusLine().getStatusCode());
    }
   
    @Test
View Full Code Here

    public void testUpdateVipCustomer() throws Exception {
        HttpPut put = new HttpPut("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold/123");
        StringWriter sw = new StringWriter();
        jaxb.createMarshaller().marshal(new Customer(123, "Raul2"), sw);
        put.setEntity(new StringEntity(sw.toString()));
        put.addHeader("Content-Type", "text/xml");
        put.addHeader("Accept", "text/xml");
        HttpResponse response = httpclient.execute(put);
        assertEquals(200, response.getStatusLine().getStatusCode());
    }
   
View Full Code Here

        HttpPut put = new HttpPut("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold/123");
        StringWriter sw = new StringWriter();
        jaxb.createMarshaller().marshal(new Customer(123, "Raul2"), sw);
        put.setEntity(new StringEntity(sw.toString()));
        put.addHeader("Content-Type", "text/xml");
        put.addHeader("Accept", "text/xml");
        HttpResponse response = httpclient.execute(put);
        assertEquals(200, response.getStatusLine().getStatusCode());
    }
   
    @Test
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.