#76 Fix ServletUnit file upload Content-Type header

closed
None
5
2008-01-14
2007-11-26
No

The "boundery" part of the Content-Type header, which is mandatory for commons-fileupload, was missing from the httprequest in the servlet.

Attached code fixes servletunit in order to be able to test a file upload servlet that has been implemented with the commons-fileupload library.

Discussion

  • Wolfgang Fahl

    Wolfgang Fahl - 2007-12-30

    Logged In: YES
    user_id=1220573
    Originator: NO

    please supply the header you'd like to parse and the result you expect so that we can fix to create what is intended.
    A Junit Test for checking parseContentTypeHeader would be great

    /**
    * Returns the content type and encoding as a pair of strings.
    * If no character set is specified, the second entry will be null.
    **/
    public static String[] parseContentTypeHeader( String header ) {
    String[] result = new String[] { "text/plain", null };
    StringTokenizer st = new StringTokenizer( header, ";=" );
    result[0] = st.nextToken();
    while (st.hasMoreTokens()) {
    String parameter = st.nextToken();
    if (st.hasMoreTokens()) {
    String value = stripQuotes( st.nextToken() );
    if (parameter.trim().equalsIgnoreCase( "charset" )) result[1] = value;
    }
    }
    return result;
    }

     
  • Wolfgang Fahl

    Wolfgang Fahl - 2007-12-30
    • assigned_to: nobody --> wolfgang_fahl
    • status: open --> pending
     
  • SourceForge Robot

    • status: pending --> closed
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.