Package org.apache.http.client.methods

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


    @Test
    public void testLanguageEnglishGiven() throws IOException {
        HttpPost post = new HttpPost(uri("/context/httpheaders/language"));
        post.setHeader("Content-Type", "text/plain");
        post.setEntity(new StringEntity("Hello world!", "UTF-8"));
        post.addHeader("Content-Language", "en");

        final HttpResponse response = client.execute(post);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
        String responseBody = asString(response);
        assertEquals("language:en:", responseBody);
View Full Code Here


    @Test
    public void testLanguageChineseGiven() throws IOException {
        HttpPost post = new HttpPost(uri("/context/httpheaders/language"));
        post.setHeader("Content-Type", "text/plain");
        post.setEntity(new StringEntity("Hello world!", "UTF-8"));
        post.addHeader("Content-Language", "zh");

        final HttpResponse response = client.execute(post);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
        String responseBody = asString(response);
        assertEquals("language:zh:", responseBody);
View Full Code Here

     * @throws java.io.IOException
     */
    @Test
    public void testCookiesOneGiven() throws IOException {
        final HttpPost HttpPost = new HttpPost(uri("/context/httpheaders/cookies"));
        HttpPost.addHeader("Cookie", "foo=bar");
        final HttpResponse response = client.execute(HttpPost);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
        String responseBody = asString(response);
        assertEquals("cookies:foo=bar:", responseBody);
    }
View Full Code Here

     * @throws java.io.IOException
     */
    @Test
    public void testCookiesManyGiven() throws IOException {
        final HttpPost post = new HttpPost(uri("/context/httpheaders/cookies"));
        post.addHeader("Cookie", "foo=bar");
        post.addHeader("Cookie", "foo2=bar2");

        final HttpResponse response = client.execute(post);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
        String responseBody = asString(response);
View Full Code Here

     */
    @Test
    public void testCookiesManyGiven() throws IOException {
        final HttpPost post = new HttpPost(uri("/context/httpheaders/cookies"));
        post.addHeader("Cookie", "foo=bar");
        post.addHeader("Cookie", "foo2=bar2");

        final HttpResponse response = client.execute(post);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
        String responseBody = asString(response);
        assertEquals("cookies:foo=bar:foo2=bar2:", responseBody);
View Full Code Here

    }
   
    @Test
    public void testPostConsumer() throws Exception {
        HttpPost post = new HttpPost("http://localhost:9000/route/customerservice/customers");
        post.addHeader("Accept" , "text/xml");
        StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        post.setEntity(entity);
        HttpClient httpclient = new DefaultHttpClient();
View Full Code Here

        if (useCompression && canSendCompressed && bytes.length > minSendAsCompressedSize) {
            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            GZIPOutputStream stream = new GZIPOutputStream(bytesOut);
            stream.write(bytes);
            stream.close();
            httpMethod.addHeader("Content-Type", "application/x-gzip");
            if (LOG.isTraceEnabled()) {
                LOG.trace("Sending compressed, size = " + bytes.length + ", compressed size = " + bytesOut.size());
            }
            bytes = bytesOut.toByteArray();
        }
View Full Code Here

   
    @Test
    public void testInvokingServiceFromClient() throws Exception {
        // just send a request which has all the namespace in the soap header
        HttpPost post = new HttpPost(simpleEndpointAddress);
        post.addHeader("Accept" , "text/xml");
       
        StringEntity entity = new StringEntity(ECHO_REQUEST, "text/xml", "ISO-8859-1");
        post.setEntity(entity);
        HttpClient httpclient = new DefaultHttpClient();
View Full Code Here

    }
   
    @Test
    public void testPostConsumer() throws Exception {
        HttpPost post = new HttpPost("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customers");
        post.addHeader("Accept" , "text/xml");
        StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        post.setEntity(entity);
        HttpClient httpclient = new DefaultHttpClient();
View Full Code Here

    }
   
    @Test
    public void testPostConsumerUniqueResponseCode() throws Exception {
        HttpPost post = new HttpPost("http://localhost:" + PORT0 + "/CxfRsRouterTest/route/customerservice/customersUniqueResponseCode");
        post.addHeader("Accept" , "text/xml");
        StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        post.setEntity(entity);
        HttpClient httpclient = new DefaultHttpClient();
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.