Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.RequestEntity.writeRequest()


        File f = new File(getClass().getResource("servicemix.jpg").getFile());
        PostMethod filePost = new PostMethod("http://localhost:8192/Service/");
        Part[] parts = {new StringPart("request", "<dummy/>"), new FilePart(f.getName(), f)};
        RequestEntity entity = new MultipartRequestEntity(parts, filePost.getParams());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        entity.writeRequest(baos);
        logger.info(baos);
        filePost.setRequestEntity(entity);
        HttpClient client = new HttpClient();
        int status = client.executeMethod(filePost);
        assertEquals(200, status);
View Full Code Here


        {
          RequestEntity requestEntity = method.getRequestEntity();
          if( requestEntity != null )
          {
            ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
            requestEntity.writeRequest( tempOut );

            byte[] compressedData = CompressionSupport.compress( compressionAlg, tempOut.toByteArray() );
            ( ( EntityEnclosingMethod )method ).setRequestEntity( new ByteArrayRequestEntity( compressedData ) );
          }
        }
View Full Code Here

        File f = new File(getClass().getResource("servicemix.jpg").getFile());
        PostMethod filePost = new PostMethod("http://localhost:18192/Service/");
        Part[] parts = {new StringPart("request", "<dummy/>"), new FilePart(f.getName(), f)};
        RequestEntity entity = new MultipartRequestEntity(parts, filePost.getParams());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        entity.writeRequest(baos);
        logger.info(baos);
        filePost.setRequestEntity(entity);
        HttpClient client = new HttpClient();
        int status = client.executeMethod(filePost);
        assertEquals(200, status);
View Full Code Here

    RequestEntity request = new MultipartRelatedRequestEntity(entry, this.getClass().getResourceAsStream("info.png"),
        "image/jpg", "asdfasdfasdf");
   
    StringWriter sw = new StringWriter();
    WriterOutputStream os = new WriterOutputStream(sw);
    request.writeRequest(os);
   
    String multipart = sw.toString();
    //System.out.println(sw.toString());
   
    assertTrue(multipart.contains("content-id: <234234@example.com>"));
View Full Code Here

            new MultipartRelatedRequestEntity(entry, this.getClass().getResourceAsStream("info.png"), "image/jpg",
                                              "asdfasdfasdf");

        StringWriter sw = new StringWriter();
        WriterOutputStream os = new WriterOutputStream(sw);
        request.writeRequest(os);

        String multipart = sw.toString();
        // System.out.println(sw.toString());

        assertTrue(multipart.contains("content-id: <234234@example.com>"));
View Full Code Here

        Part[] parts = {
            new StringPart("request", "<dummy/>"),
            new FilePart(f.getName(), f) };
        RequestEntity entity = new MultipartRequestEntity(parts, filePost.getParams());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        entity.writeRequest(baos);
        System.err.println(baos);
        filePost.setRequestEntity(entity);
        HttpClient client = new HttpClient();
        int status = client.executeMethod(filePost);
        assertEquals(200, status);
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.