Package org.apache.http.client.methods

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


    private HttpDelete doDelete() {
        HttpDelete method = new HttpDelete(requestURI);

        for (Header header : headers) {
            method.addHeader(header);
        }

        return method;
    }
View Full Code Here


    }

    public HttpResponse doDelete(DefaultHttpClient httpClient, String resourcePath) {
        try {
            HttpDelete httpDelete = new HttpDelete(resourcePath);
            httpDelete.addHeader("Content-Type", "application/json");

            String userPass = username + ":" + password;
            String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
            httpDelete.addHeader("Authorization", basicAuth);
View Full Code Here

            HttpDelete httpDelete = new HttpDelete(resourcePath);
            httpDelete.addHeader("Content-Type", "application/json");

            String userPass = username + ":" + password;
            String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
            httpDelete.addHeader("Authorization", basicAuth);

            httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient);

            HttpParams params = httpClient.getParams();
            HttpConnectionParams.setConnectionTimeout(params, TIME_OUT_PARAM);
View Full Code Here

  @Override
  protected ClientResponse delete(String url) throws IOException
  {
    HttpDelete deleteMethod = new HttpDelete(url);
    deleteMethod.addHeader("accept", "application/json");

    return execute(deleteMethod);
  }

  private ClientResponse execute(HttpUriRequest request) throws IOException
View Full Code Here

            .accept("text/plain").post(null, String.class);
        assertEquals("ok", r);
       
        HttpClient httpclient = new DefaultHttpClient();
        HttpDelete httpdelete = new HttpDelete("http://localhost:" + PORT + "/untest/delete");
        httpdelete.addHeader("Origin", "http://localhost:" + PORT);

        HttpResponse response = httpclient.execute(httpdelete);
        assertEquals(200, response.getStatusLine().getStatusCode());
        assertAllowCredentials(response, false);
        assertOriginResponse(true, null, true, response);
View Full Code Here

        DefaultHttpClient httpClient = new DefaultHttpClient();
        httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM),
        new UsernamePasswordCredentials(user, new String(pass)));
        HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 10000);
        HttpDelete httpDelete = new HttpDelete(url);
        httpDelete.addHeader("accept", "application/json");

        HttpResponse response = httpClient.execute(httpDelete);

        int statusCode = response.getStatusLine().getStatusCode();
View Full Code Here

            .accept("text/plain").post(null, String.class);
        assertEquals("ok", r);
       
        HttpClient httpclient = new DefaultHttpClient();
        HttpDelete httpdelete = new HttpDelete("http://localhost:" + PORT + "/untest/delete");
        httpdelete.addHeader("Origin", "http://localhost:" + PORT);

        HttpResponse response = httpclient.execute(httpdelete);
        assertEquals(200, response.getStatusLine().getStatusCode());
        assertAllowCredentials(response, false);
        assertOriginResponse(true, null, true, response);
View Full Code Here

    }
   
    @Test
    public void testDeleteVipCustomer() throws Exception {
        HttpDelete delete = new HttpDelete("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold/123");
        delete.addHeader("Accept", "text/xml");
        HttpResponse response = httpclient.execute(delete);
        assertEquals(200, response.getStatusLine().getStatusCode());
    }
   
    @Test
View Full Code Here

        // add headers to request
        if (headers != null && headers.size() > 0) {
            for (String header : headers.keySet()) {
                String value = headers.get(header);
                request.addHeader(header, value);

                if (logger.isDebugEnabled()) {
                    logger.debug("adding header: " + header + " = " + value);
                }
            }
View Full Code Here

  @Test
  public void deleteSuccessful() throws Exception {
    Long id = parseEntity(createSample().getEntity(), Long.class);

    HttpDelete request = new HttpDelete(url + "/bookmark/" + id);
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    CloseableHttpResponse response = client.execute(request);
    response.close();
    assertEquals(SC_NO_CONTENT, 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.