Package org.apache.commons.httpclient.methods.multipart

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


        if( nodeProperties.size() > 0) {
            if(multiPart) {
                final List<Part> partList = new ArrayList<Part>();
                for(Map.Entry<String,String> e : nodeProperties.entrySet()) {
                    if (e.getValue() != null) {
                        partList.add(new StringPart(e.getKey().toString(), e.getValue().toString(), "UTF-8"));
                    }
                }
                final Part [] parts = partList.toArray(new Part[partList.size()]);
                post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
            } else {
View Full Code Here


        throws IOException {

        final Part[] parts = new Part[typeHint == null ? 1 : 2];
        parts[0] = new FilePart(fieldName, localFile);
        if (typeHint != null) {
            parts[1] = new StringPart(fieldName + "@TypeHint", typeHint);
        }
        final PostMethod post = new PostMethod(url);
        post.setFollowRedirects(false);
        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
View Full Code Here

      List<Part> partsList = new ArrayList<Part>();
      for (int i=0; i < localFiles.length; i++) {
            Part filePart = new FilePart(fieldNames[i], localFiles[i]);
            partsList.add(filePart);
            if (typeHints != null) {
              Part typeHintPart = new StringPart(fieldNames[i] + "@TypeHint", typeHints[i]);
              partsList.add(typeHintPart);
            }
    }
     
        final Part[] parts = partsList.toArray(new Part[partsList.size()]);
View Full Code Here

        PostMethod filePost = new PostMethod(targetURL + "/install");

        try {

            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

       
        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

        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

     * @param parameterName The name of the parameter.
     * @param parameterValue The value of the parameter.
     */
    public void addParameter(String parameterName, String parameterValue) {
        LOG.trace("enter addParameter(String parameterName, String parameterValue)");
        Part param = new StringPart(parameterName, parameterValue);
        parameters.add(param);
    }
View Full Code Here

     * @param parameterName The name of the parameter.
     * @param parameterValue The value of the parameter.
     */
    public void addParameter(String parameterName, String parameterValue) {
        LOG.trace("enter addParameter(String parameterName, String parameterValue)");
        Part param = new StringPart(parameterName, parameterValue);
        parameters.add(param);
    }
View Full Code Here

    try {
      PostMethod post = new PostMethod(url);
      post.setRequestHeader("User-Agent", "anonymous");
      ArrayList al = new ArrayList();
      for (int k = 0; k < fields.length; k++) {
        al.add(new StringPart(fields[k][0], fields[k][1]));
      }
      if (files != null) {
        for (int i = 0; i < files.length; i++) {
          File f = files[i];
          al.add(new FilePart(f.getName(), f));
View Full Code Here

    System.out.println("Executing POST request to " +formAction);
    PostMethod post = new PostMethod(formAction);
    post.addRequestHeader("accept", "text/plain");
    try {
      Part[] parts = new Part[] {
          new StringPart("username", username),
          new StringPart("password", password),
          new StringPart("ontologyUri", ontologyUri),
          new FilePart("ontologyFile", partSource),
          new StringPart("graphId", graphId),
      };
      post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
      HttpClient client = new HttpClient();
      client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.multipart.StringPart

Copyright © 2018 www.massapicom. 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.