Debugging a Simple multipart/form-data POST request - TCP-IP

This is a discussion on Debugging a Simple multipart/form-data POST request - TCP-IP ; I've got two POST requests below, POSTed via Firefox. One works, and I can't figure out why one doesn't. #1) From XMLHttpRequest #2) Posted via Firefox form "normal" form submission handling (internal browser mechanism) Results are: #1, HTTP/1.x 500 Internal ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Debugging a Simple multipart/form-data POST request

  1. Debugging a Simple multipart/form-data POST request

    I've got two POST requests below, POSTed via Firefox. One works, and I
    can't figure out why one doesn't.

    #1) From XMLHttpRequest
    #2) Posted via Firefox form "normal" form submission handling
    (internal browser mechanism)

    Results are:
    #1, HTTP/1.x 500 Internal Server Error
    #2, HTTP/1.x 200 OK

    What's wrong with the request?

    The FORM has been reduced to one input field and a BUTTON element.

    The first request is the one that results in 500. It is easily
    distinguishable by the boundary "DATA1215979532633", by the content-
    type header having "charset=UTF-8;" and the extra cache headers
    appended. But I can't figure out what's wrong with it.


    Live HTTP Headers' "HTTP Headers" Tab Results:----------------------
    http://localhost/ape/release/example/form/process.jsp



    POST /ape/release/example/form/process.jsp HTTP/1.1

    Host: localhost

    User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:
    1.9) Gecko/2008061004 Firefox/3.0

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
    *;q=0.8

    Accept-Language: en-us,en;q=0.5

    Accept-Encoding: gzip,deflate

    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

    Keep-Alive: 300

    Connection: keep-alive

    Content-Type: multipart/form-data; charset=UTF-8;
    boundary=DATA1215979532633

    Referer: http://localhost/ape/release/example/form/Form.html

    Content-Length: 91

    Cookie: JSESSIONID=242B477B4C9455A201CF1BF7D5CFCE16

    Pragma: no-cache

    Cache-Control: no-cache


    --DATA1215979532633
    Content-Disposition: form-data; name="name";

    a
    --DATA1215979532633--


    HTTP/1.x 500 Internal Server Error

    Server: Apache-Coyote/1.1

    Content-Type: text/html;charset=utf-8

    Content-Length: 3840

    Date: Sun, 13 Jul 2008 20:05:32 GMT

    Connection: close

    ----------------------------------------------------------

    http://localhost/ape/release/example/form/process.jsp



    POST /ape/release/example/form/process.jsp HTTP/1.1

    Host: localhost

    User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:
    1.9) Gecko/2008061004 Firefox/3.0

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
    *;q=0.8

    Accept-Language: en-us,en;q=0.5

    Accept-Encoding: gzip,deflate

    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

    Keep-Alive: 300

    Connection: keep-alive

    Referer: http://localhost/ape/release/example/form/Form.html

    Cookie: JSESSIONID=242B477B4C9455A201CF1BF7D5CFCE16

    Content-Type: multipart/form-data;
    boundary=---------------------------1055457295855832845137158309

    Content-Length: 170

    -----------------------------1055457295855832845137158309

    Content-Disposition: form-data; name="name"



    a

    -----------------------------1055457295855832845137158309--



    HTTP/1.x 200 OK

    Server: Apache-Coyote/1.1

    Content-Encoding: gzip

    Content-Type: text/plain

    Transfer-Encoding: chunked

    Date: Sun, 13 Jul 2008 20:10:15 GMT

    ----------------------------------------------------------




  2. Re: Debugging a Simple multipart/form-data POST request

    On Sun, 13 Jul 2008 13:38:57 -0700, Galaxy wrote:

    > I've got two POST requests below, POSTed via Firefox. One works, and I
    > can't figure out why one doesn't.
    >
    > #1) From XMLHttpRequest
    > #2) Posted via Firefox form "normal" form submission handling (internal
    > browser mechanism)
    >
    > Results are:
    > #1, HTTP/1.x 500 Internal Server Error #2, HTTP/1.x 200 OK
    >
    > What's wrong with the request?


    Nothing per se I think, I guess your perl script dies. Look in the
    errorlog of the webserver.

    M4

  3. Re: Debugging a Simple multipart/form-data POST request

    On Jul 14, 12:47*pm, Martijn Lievaart wrote:
    > On Sun, 13 Jul 2008 13:38:57 -0700, Galaxy wrote:
    > > I've got two POST requests below, POSTed via Firefox. One works, and I
    > > can't figure out why one doesn't.

    >
    > > #1) From XMLHttpRequest
    > > #2) Posted via Firefox form "normal" form submission handling (internal
    > > browser mechanism)

    >
    > > Results are:
    > > #1, HTTP/1.x 500 Internal Server Error #2, HTTP/1.x 200 OK

    >
    > > What's wrong with the request?

    >
    > Nothing per se I think, I guess your perl script dies. Look in the
    > errorlog of the webserver.
    >


    I get the Java error: "Stream ended unexpectedly"

    The post body is sent over XMLHttpRequest and always has the error.
    (the submission always works fine
    if sent via "normal" form submission). There seems to be a problem
    with the request. Bad headers, or content-length incorrect?

    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:
    515)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:
    408)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:
    320)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
    com.jspinsider.jspkit.gzip.GZIPFilter.doFilter(Unk nown Source)

    root cause

    javax.servlet.ServletException:
    org.apache.commons.fileupload.FileUploadException

    : Processing of multipart/form-data request failed.
    Stream ended unexpectedly
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^

    The java code:
    // Create a factory for disk-based file items
    FileItemFactory factory = new DiskFileItemFactory();

    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);

    List items = upload.parseRequest(request);
    response.setContentType("text/plain");
    out.write(items.toString());

    Garrett

    > M4



  4. Re: Debugging a Simple multipart/form-data POST request

    On Mon, 14 Jul 2008 21:50:06 -0700, dhtml wrote:

    > The post body is sent over XMLHttpRequest and always has the error. (the
    > submission always works fine
    > if sent via "normal" form submission). There seems to be a problem with
    > the request. Bad headers, or content-length incorrect?


    Well, I cannot see anything wrong with it. Maybe look with wireshark at a
    good and a bad request?

    M4

+ Reply to Thread