Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Created December 14, 2013 06:34
Show Gist options
  • Save cuipengfei/7956259 to your computer and use it in GitHub Desktop.
Save cuipengfei/7956259 to your computer and use it in GitHub Desktop.
learn you node http uppercase
var http = require('http')
var map = require('through2-map')
var port = process.argv[2]
http.createServer(function (request, response) {
request
.pipe(map(function (chunk) {
return chunk.toString().toUpperCase()
}))
.pipe(response)
}).listen(port)
@maxwell-oroark
Copy link

is there an alternative to calling the .toString() method here?

I was trying the setEncoding() on the request argument which is a stream but it still wouldn't let me.

Wondering why I can use that method here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment