Skip to content

Instantly share code, notes, and snippets.

@rolandboon
Created September 20, 2012 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolandboon/3754694 to your computer and use it in GitHub Desktop.
Save rolandboon/3754694 to your computer and use it in GitHub Desktop.
Test case POST-data encoding
http = require('http')
post_body = 'track=%3A)'
headers =
'Accept': '*/*',
'Connection': 'close',
'Host': 'rolandboon.com',
'Content-length': Buffer.byteLength(post_body)
'Content-Type': 'application/x-www-form-urlencoded';
options =
host: 'test.rolandboon.com',
port: 80,
path: '/postdata.php',
method: 'POST',
headers: headers
data = ''
request = http.request(options)
request.on "response", (response) ->
response.on "data", (chunk) ->
data += chunk
response.on "end", ->
console.log data
request.write(post_body)
request.end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment