Created
December 8, 2011 17:26
-
-
Save jbilcke/1447709 to your computer and use it in GitHub Desktop.
common-coffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# with common-node | |
httpclient = require "httpclient" | |
exports.app = -> | |
status: 200 | |
headers: {} | |
body: new httpclient.HttpClient(url: "http://google.com").finish().body | |
# without | |
http = require "http" | |
http.createServer((req, res) -> | |
res.writeHead 200, {} | |
http.get | |
host: "google.com" | |
port: 80 | |
path: "/" | |
, (r) -> | |
chunks = [] | |
r.on "data", (chunk) -> | |
chunks.push chunk | |
r.on "end", -> | |
chunks.forEach (chunk) -> | |
res.write chunk | |
res.end() | |
).listen 8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment