Examples of StringPart


Examples of com.ning.http.multipart.StringPart

    public static Response POST(Request request, Object url, Map<String, String> parameters, Map<String, File> files) {
        List<Part> parts = new ArrayList<Part>();

        for (String key : parameters.keySet()) {
            parts.add(new StringPart(key, parameters.get(key)));
        }

        for (String key : files.keySet()) {
            Part filePart;
            try {
View Full Code Here

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

   @Test
   public void testPost() throws Exception
   {
      HttpClient client = new HttpClient();
      List<Part> partsList = new ArrayList<Part>();
      partsList.add(new StringPart("part1", "This is Value 1"));
      partsList.add(new StringPart("part2", "This is Value 2"));
      partsList.add(new FilePart("data.txt", LocateTestData.getTestData("data.txt")));
      Part[] parts = partsList.toArray(new Part[partsList.size()]);
      PostMethod method = new PostMethod(TEST_URI);
      RequestEntity entity = new MultipartRequestEntity(parts, method.getParams());
      method.setRequestEntity(entity);
View Full Code Here

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

        server.start();
           
        PostMethod filePost = new PostMethod("http://localhost:" + server.getLocalPort() + "/");
        org.apache.commons.httpclient.HttpClient client = new org.apache.commons.httpclient.HttpClient();
           
        Part part1 = new StringPart("part1", "0123456789\r\n");
        Part part2 = new StringPart("part2", "567890\r\n");
        Part part3 = new StringPart("part3", "3456\r\n");
       
        HttpMethodParams params = new HttpMethodParams();
        params.setBooleanParameter("testb", false);
        filePost.setRequestEntity(new MultipartRequestEntity(new Part[] {part1, part2, part3 }, params));
           
View Full Code Here

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

   @Test
   public void testPut() throws Exception
   {
      HttpClient client = new HttpClient();
      List<Part> partsList = new ArrayList<Part>();
      partsList.add(new StringPart("part1", "This is Value 1"));
      partsList.add(new StringPart("part2", "This is Value 2"));
      partsList.add(new FilePart("data.txt", LocateTestData
              .getTestData("data.txt")));
      Part[] parts = partsList.toArray(new Part[partsList.size()]);
      PutMethod method = new PutMethod(TEST_URI);
      RequestEntity entity = new MultipartRequestEntity(parts, method
View Full Code Here

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

   private void testMultipart(String uri) throws JAXBException, IOException
   {
      HttpClient client = new HttpClient();
      List<Part> partsList = new ArrayList<Part>();
      StringPart part = new StringPart("bill", createCustomerData("bill"));
      part.setContentType("application/xml");
      partsList.add(part);
      StringPart part1 = new StringPart("monica",
              createCustomerData("monica"));
      part1.setContentType("application/xml");
      partsList.add(part1);
      Part[] parts = partsList.toArray(new Part[partsList.size()]);
      PutMethod method = new PutMethod(uri);
      RequestEntity entity = new MultipartRequestEntity(parts, method
              .getParams());
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

                }

                Object propValue = property.getValue();

                if (propValue instanceof String) {
                    parts.add(new StringPart(property.getKey(), (String) propValue));
                } else if (property != null) {
                    // TODO handle multi-valued properties
                    System.err.println("Unable to handle property " + property.getKey() + " of type "
                            + property.getValue().getClass());
                }
View Full Code Here

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

    @Override
    public Result<Void> execute() {
        PostMethod post = new PostMethod(getPath());
      try{
        Part[] parts ={new StringPart(":operation", "delete")};
        post.setRequestEntity(new MultipartRequestEntity(parts,post.getParams()));
        httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(repositoryInfo.getUsername(),repositoryInfo.getPassword()));
        httpClient.getParams().setAuthenticationPreemptive(true);
        int responseStatus=httpClient.executeMethod(post);
       
View Full Code Here

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

        try {
            // set referrer
            filePost.setRequestHeader("referer", "about:blank");

            List<Part> partList = new ArrayList<Part>();
            partList.add(new StringPart("action", "install"));
            partList.add(new StringPart("_noredir_", "_noredir_"));
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            IOUtils.copy(in, baos);
            PartSource partSource = new ByteArrayPartSource(fileName, baos.toByteArray());
            partList.add(new FilePart("bundlefile", partSource));
            partList.add(new StringPart("bundlestart", "start"));

            Part[] parts = partList.toArray(new Part[partList.size()]);

            filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));
View Full Code Here

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

        try {
            // set referrer
            filePost.setRequestHeader("referer", "about:blank");

            List<Part> partList = new ArrayList<Part>();
            partList.add(new StringPart("action", "install"));
            partList.add(new StringPart("_noredir_", "_noredir_"));
            partList.add(new FilePart("bundlefile", new FilePartSource(
                file.getName(), file)));
            partList.add(new StringPart("bundlestartlevel", bundleStartLevel));

            if (bundleStart) {
                partList.add(new StringPart("bundlestart", "start"));
            }

            if (refreshPackages) {
                partList.add(new StringPart("refreshPackages", "true"));
            }

            Part[] parts = partList.toArray(new Part[partList.size()]);

            filePost.setRequestEntity(new MultipartRequestEntity(parts,
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.