-
-
Save igorw/75aae212a11ab642f864 to your computer and use it in GitHub Desktop.
This file contains 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
var http = require('http'); | |
function handle(req, rep) { | |
req.pipe(process.stdout); | |
req.on('end', function () { | |
rep.end(); | |
console.log(''); | |
}); | |
} | |
var server = http.createServer(handle); | |
server.on('checkContinue', function (req, rep) { | |
if (!req.headers['x-foo']) { | |
console.log('did not have foo'); | |
rep.writeHead(400); | |
rep.end(); | |
return; | |
} | |
rep.writeContinue(); | |
handle(req, rep); | |
}); | |
server.listen(8080); |
This file contains 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
~$ curl localhost:8080 -d{0..1023} -H 'X-Foo: value' -v | |
* About to connect() to localhost port 8080 (#0) | |
* Trying ::1... | |
* Connection refused | |
* Trying 127.0.0.1... | |
* connected | |
* Connected to localhost (127.0.0.1) port 8080 (#0) | |
> POST / HTTP/1.1 | |
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5 | |
> Host: localhost:8080 | |
> Accept: */* | |
> X-Foo: value | |
> Content-Length: 4009 | |
> Content-Type: application/x-www-form-urlencoded | |
> Expect: 100-continue | |
> | |
< HTTP/1.1 100 Continue | |
< HTTP/1.1 200 OK | |
< Date: Fri, 03 May 2013 02:06:47 GMT | |
< Connection: keep-alive | |
< Transfer-Encoding: chunked | |
< | |
* Connection #0 to host localhost left intact | |
* Closing connection #0 |
This file contains 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
~$ curl localhost:8080 -d{0..1023} -v | |
* About to connect() to localhost port 8080 (#0) | |
* Trying ::1... | |
* Connection refused | |
* Trying 127.0.0.1... | |
* connected | |
* Connected to localhost (127.0.0.1) port 8080 (#0) | |
> POST / HTTP/1.1 | |
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5 | |
> Host: localhost:8080 | |
> Accept: */* | |
> Content-Length: 4009 | |
> Content-Type: application/x-www-form-urlencoded | |
> Expect: 100-continue | |
> | |
< HTTP/1.1 400 Bad Request | |
< Date: Fri, 03 May 2013 02:07:41 GMT | |
< Connection: close | |
< Transfer-Encoding: chunked | |
< | |
* Closing connection #0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment