Examples of StringPart


Examples of org.apache.commons.httpclient.methods.multipart.StringPart

         *
         * @param paramName
         * @param value
         */
        private void addPart(String paramName, String value) {
            parts.add(new StringPart(paramName, value));
        }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

            switch (value.getType()) {
                case PropertyType.BINARY:
                    part = new FilePart(paramName, new BinaryPartSource(value));
                    break;
                case PropertyType.NAME:
                    part = new StringPart(paramName, resolver.getJCRName(value.getName()));
                    break;
                case PropertyType.PATH:
                    part = new StringPart(paramName, resolver.getJCRPath(value.getPath()));
                    break;
                default:
                    part = new StringPart(paramName, value.getString());
            }
            String ctype = JcrValueType.contentTypeFromType(value.getType());
            ((PartBase) part).setContentType(ctype);

            parts.add(part);
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

        file.delete();
        assertEquals(resp1, resp2);
    }

    public void testStringPartResendsData() throws Exception {
        StringPart part = new StringPart(NAME, PART_DATA);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp1 = stream.toString();
        stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp2 = stream.toString();
        assertEquals(resp1, resp2);
    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

        File file = new File("src/main/resources/META-INF/NOTICE.txt");

        PostMethod httppost = new PostMethod("http://localhost:9080/test");
        Part[] parts = {
            new StringPart("comment", "A binary file of some kind"),
            new FilePart(file.getName(), file)
        };

        MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
        httppost.setRequestEntity(reqEntity);
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

       
        this.server.setHttpService(new EchoService());
       
        PostMethod method = new PostMethod();
        MultipartRequestEntity entity = new MultipartRequestEntity(
            new Part[] { new StringPart("param", "Hello", "ISO-8859-1") },
            method.getParams());
        method.setRequestEntity(entity);
        client.executeMethod(method);

        assertEquals(200,method.getStatusCode());
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

               HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
               String parameterName = arg.getName();
               if (arg.isSkippable(parameterName)){
                   continue;
               }
               partlist.add(new StringPart(arg.getName(), arg.getValue(), contentEncoding));
            }

            // Add any files
            for (int i=0; i < files.length; i++) {
                HTTPFileArg file = files[i];
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

    @Test
    public void testUpload() throws Exception {
      File toupload = folder.newFile("Jojo");
      PostMethod pm = new PostMethod(serverurl+"/"+resourceUrl);
      Part[] parts = {
          new StringPart("originalname", toupload.getAbsolutePath(),"UTF-8"),
          new StringPart("filename", toupload.getName(),"UTF-8"),
          new FilePart("file", toupload)
      };
     
      pm.setRequestEntity(new MultipartRequestEntity(parts, pm.getParams()));
      HttpClient cl = new HttpClient();
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

                HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
                String parameterName = arg.getName();
                if (arg.isSkippable(parameterName)){
                    continue;
                }
                StringPart part = new StringPart(arg.getName(), arg.getValue(), contentEncoding);
                if (browserCompatible) {
                    part.setTransferEncoding(null);
                    part.setContentType(null);
                }
                partlist.add(part);
            }

            // Add any files
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

                String p = iter.next();
                String[] vals = params.getParams(p);
                if (vals != null) {
                  for (String v : vals) {
                    if (this.useMultiPartPost || isMultipart) {
                      parts.add(new StringPart(p, v, "UTF-8"));
                    } else {
                      post.addParameter(p, v);
                    }
                  }
                }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.multipart.StringPart

    public void testSendMultiPartForm() throws Exception {
        HttpClient httpclient = new HttpClient();
        File file = new File("src/main/resources/META-INF/NOTICE.txt");
        PostMethod httppost = new PostMethod("http://localhost:9080/test");
        Part[] parts = {
            new StringPart("comment", "A binary file of some kind"),
            new FilePart(file.getName(), file)
        };

        MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
        httppost.setRequestEntity(reqEntity);
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.