1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5const CC = Components.Constructor;
6const BinaryInputStream = CC(
7  "@mozilla.org/binaryinputstream;1",
8  "nsIBinaryInputStream",
9  "setInputStream"
10);
11
12function handleRequest(request, response) {
13  var body = "<html>\
14    <body>\
15    Inner POST data: ";
16
17  var bodyStream = new BinaryInputStream(request.bodyInputStream);
18  var bytes = [],
19    avail = 0;
20  while ((avail = bodyStream.available()) > 0) {
21    body += String.fromCharCode.apply(String, bodyStream.readByteArray(avail));
22  }
23
24  body +=
25    '<form id="postForm" action="post_form_inner.sjs" method="post">\
26     <input type="text" name="inputfield" value="inner">\
27     <input type="submit">\
28     </form>\
29     </body>\
30     </html>';
31
32  response.bodyOutputStream.write(body, body.length);
33}
34