Package org.apache.http.entity.mime

Examples of org.apache.http.entity.mime.MultipartEntity.addPart()


        setHost(vhost); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service
      if (vhost == null) setHost("127.0.0.1");

        final MultipartEntity multipartEntity = new MultipartEntity();
        for (final Entry<String,ContentBody> part : post.entrySet())
            multipartEntity.addPart(part.getKey(), part.getValue());
        // statistics
        this.upbytes = multipartEntity.getContentLength();

        if (usegzip) {
            httpPost.setEntity(new GzipCompressingEntity(multipartEntity));
View Full Code Here


               }
               FormBodyPart formPart;
               StringBody stringBody = new StringBody(arg.getValue(),
                       Charset.forName(contentEncoding == null ? "US-ASCII" : contentEncoding));
               formPart = new FormBodyPart(arg.getName(), stringBody);                  
               multiPart.addPart(formPart);
            }

            // Add any files
            // Cannot retrieve parts once added to the MultiPartEntity, so have to save them here.
            ViewableFileBody[] fileBodies = new ViewableFileBody[files.length];
View Full Code Here

            // Cannot retrieve parts once added to the MultiPartEntity, so have to save them here.
            ViewableFileBody[] fileBodies = new ViewableFileBody[files.length];
            for (int i=0; i < files.length; i++) {
                HTTPFileArg file = files[i];
                fileBodies[i] = new ViewableFileBody(new File(file.getPath()), file.getMimeType());
                multiPart.addPart(file.getParamName(),fileBodies[i]);
            }

            post.setEntity(multiPart);

            if (multiPart.isRepeatable()){
View Full Code Here

        assertNull(p2);
    }

    public void testRepeatable() throws Exception {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("p1", new StringBody("blah blah"));
        entity.addPart("p2", new StringBody("yada yada"));
        assertTrue(entity.isRepeatable());
        assertFalse(entity.isChunked());
        assertFalse(entity.isStreaming());
View Full Code Here

    }

    public void testRepeatable() throws Exception {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("p1", new StringBody("blah blah"));
        entity.addPart("p2", new StringBody("yada yada"));
        assertTrue(entity.isRepeatable());
        assertFalse(entity.isChunked());
        assertFalse(entity.isStreaming());

        long len = entity.getContentLength();
View Full Code Here

        assertTrue(bytes.length == len);
    }

    public void testNonRepeatable() throws Exception {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("p1", new InputStreamBody(
                new ByteArrayInputStream("blah blah".getBytes()), null));
        entity.addPart("p2", new InputStreamBody(
                new ByteArrayInputStream("yada yada".getBytes()), null));
        assertFalse(entity.isRepeatable());
        assertTrue(entity.isChunked());
View Full Code Here

    public void testNonRepeatable() throws Exception {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("p1", new InputStreamBody(
                new ByteArrayInputStream("blah blah".getBytes()), null));
        entity.addPart("p2", new InputStreamBody(
                new ByteArrayInputStream("yada yada".getBytes()), null));
        assertFalse(entity.isRepeatable());
        assertTrue(entity.isChunked());
        assertTrue(entity.isStreaming());
View Full Code Here

   
    public void uninstallBundle(String symbolicName, File f) throws Exception {
        final long bundleId = getBundleId(symbolicName);
       
        final MultipartEntity entity = new MultipartEntity();
        entity.addPart("action",new StringBody("uninstall"));
        executor.execute(
                builder.buildPostRequest(CONSOLE_BUNDLES_PATH+"/"+bundleId)
                .withCredentials(username, password)
                .withEntity(entity)
        ).assertStatus(200);
View Full Code Here

    /** Install a bundle using the Felix webconsole HTTP interface, with a specific start level */
    public void installBundle(File f, boolean startBundle, int startLevel) throws Exception {
       
        // Setup request for Felix Webconsole bundle install
        final MultipartEntity entity = new MultipartEntity();
        entity.addPart("action",new StringBody("install"));
        if(startBundle) {
            entity.addPart("bundlestart", new StringBody("true"));
        }
        entity.addPart("bundlefile", new FileBody(f));
       
View Full Code Here

       
        // Setup request for Felix Webconsole bundle install
        final MultipartEntity entity = new MultipartEntity();
        entity.addPart("action",new StringBody("install"));
        if(startBundle) {
            entity.addPart("bundlestart", new StringBody("true"));
        }
        entity.addPart("bundlefile", new FileBody(f));
       
        if(startLevel > 0) {
            entity.addPart("bundlestartlevel", new StringBody(String.valueOf(startLevel)));
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.