commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garrett Smith" <dhtmlkitc...@gmail.com>
Subject Re: "Stream ended unexpectedly" - simple testcase
Date Thu, 17 Jul 2008 16:24:18 GMT
On Thu, Jul 17, 2008 at 7:00 AM, Aaron Freeman <aaron@sendthisfile.com> wrote:
> Shouldn't there be a newline after the content ("a")? In otherwords
> shouldn't --DATA1215979532633-- be on its own line?
>

I think you're right.

req.send('--DATA1215979532633\r\n'
    +'Content-Disposition: form-data; name="name";'
    +'\r\na\r\n'
    +'--DATA1215979532633--');


But I still get the error: "Stream ended unexpectedly."

Full source code:
============================================
<!DOCTYPE HTML>
<html lang="en">
<head>
  <title>Form Serialize</title>
</head>
<body>
<form method="post"
  enctype="multipart/form-data"
  id='form' action="process.jsp">
  <input type="text" name="name" value="a"/>
  <button type="button"
    onclick="sendXHR(event);return false;">Send</button>
</form>

<pre id="result"></pre>

<script>
function sendXHR(e) {try{
  var req = new XMLHttpRequest();
  req.oreadystatechange = showData;
  req.open("post", "process.jsp", true);
  req.setRequestHeader('Content-Type',
    "multipart/form-data; boundary=DATA1215979532633");
  req.send('--DATA1215979532633\r\n'
    +'Content-Disposition: form-data; name="name";'
    +'\r\na\r\n'
    +'--DATA1215979532633--');
    }catch(ex){alert(ex);}
}


function showData() {
  var data = this.responseText;
  document.getElementById('result').innerHTML = data;
}
</script>
</body>
</html>
============================================

Garrett
> -a
>
>>
[snip "-----Original Message-----"]

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message