Package org.apache.http.client.methods

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


        mock.message(0).body().isInstanceOf(Customer.class);

        HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/customers");
        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        put.addHeader("test", "header1;header2");
        put.setEntity(entity);
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();

        try {
            HttpResponse response = httpclient.execute(put);
View Full Code Here


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

        try {
            HttpResponse response = httpclient.execute(put);
View Full Code Here

    @Test
    public void testPutConsumer() throws Exception {
        HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/customers");
        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        put.addHeader("test", "header1;header2");
        put.setEntity(entity);
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(put);
View Full Code Here

        return new Result(response, data);
    }

    private Result put(String path, byte[] body, int... expectedStatus) throws IOException {
        HttpPut put = new HttpPut(baseUri + path);
        put.addHeader("Content-Type", "application/json");
        put.setEntity(new ByteArrayEntity(body));
        HttpResponse response = httpclient.execute(put);

        byte[] data = checkStatusAndReadResponse(path, response, expectedStatus);
View Full Code Here

  {
    HttpPut put = new HttpPut(url);
    put.setEntity(entity);
    for (String header : headers.keySet())
    {
      put.addHeader(header, headers.get(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, headers.get(header));
    }
    if (entity.getContentType() == null && !put.containsHeader(HttpHeaders.CONTENT_TYPE))
    {
      put.addHeader(HttpHeaders.CONTENT_TYPE, HTTP.DEF_CONTENT_CHARSET.name());
    }
    try
    {
      this.execute(put, new VoidResponseHandler());
    }
View Full Code Here

    @Test
    public void testPutConsumer() throws Exception {
        HttpPut put = new HttpPut("http://localhost:9000/rest/customerservice/customers");
        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        put.addHeader("test", "header1;header2");
        put.setEntity(entity);
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(put);
View Full Code Here

        HttpPut putMethod = new HttpPut(signedAclUrl);

        if(acl != null) {
            String restHeaderAclValue = acl.getValueForRESTHeaderACL();
            if(restHeaderAclValue != null) {
                putMethod.addHeader(this.getRestHeaderPrefix() + "acl", restHeaderAclValue);
            }
            else {
                String aclAsXml = acl.toXml();
                putMethod.setEntity(new StringEntity(
                        aclAsXml, ContentType.create("text/plain", Constants.DEFAULT_ENCODING)));
View Full Code Here

        requestPost.addHeader("Content-type", "application/json");
        return requestPost;
      case PUT:
        HttpPut requestPut = new HttpPut(urlString);
        requestPut.setEntity(new ByteArrayEntity(jsonPayload.getBytes()));
        requestPut.addHeader("Content-type", "application/json");
        return requestPut;
      case DELETE:
        HttpDelete requestDelete = new HttpDelete(urlString);
        return requestDelete;
      default:
View Full Code Here

            return response;
        }

        HttpPut httpPut = createHttpPutMethod(details, uploadUrl);
        // add the 100 continue directive
        httpPut.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);

        FileEntity fileEntity = new FileEntity(details.file, "binary/octet-stream");

        response = httpClient.upload(httpPut, fileEntity);
        int statusCode = response.getStatusLine().getStatusCode();
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.