Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@aseemk /app.js
Created Apr 29, 2011

Node or Connect bug: form decoding / body parsing
var express = require('express');
var app = express.createServer();
app.set('views', __dirname);
app.set('view engine', 'html');
app.register('.html', require('ejs'));
app.configure(function () {
dumpExceptions: true,
showStack: true
app.get('/', function (req, resp) {
resp.render('index.html', {
url: req.url
});'/', function (req, resp) {
resp.render('success.html', {
data: req.body
console.log('Visit http://localhost:8888/ in your browser.');
function bookmarklet() {
var form = document.createElement('form');
var input = document.createElement('input');
input.type = 'hidden'; = 'title';
input.value = document.title;
form.action = 'http://<%= host %><%= url %>';
form.method = 'post'; = '_blank';
<p>Drag this bookmarklet up to your bookmarks bar:</p>
document.write('<a href="javascript:(' + bookmarklet + ')();">Test</a>');
Then click it from any of these Amazon pages:
<li><a href="">
The Machinist</a></li>
<li><a href="">
Family Guy Presents Stewie Griffin</a></li>
<li><a href="">
The Bourne Ultimatum</a></li>
<li><a href="">
<p>Does it work? Or do you see an error page?</p>
<!doctype html>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Node/Connect form decoding bug?</title>
<%- body %>
<p>Success! It worked. Here's the data we received:</p>
<pre><%= JSON.stringify(data) %></pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.