You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
790 B

  1. var connect = require('./');
  2. var app = connect();
  3. app.use(connect.logger('dev'));
  4. app.use(connect.bodyParser());
  5. app.use(function(req, res, next){
  6. if (req.checkContinue) {
  7. res.writeContinue();
  8. }
  9. res.end('hello');
  10. });
  11. var server = app.listen(3000);
  12. server.on('checkContinue', function(req, res){
  13. req.checkContinue = true;
  14. app(req, res);
  15. });
  16. // var http = require('http');
  17. // var app = http.createServer(function(req, res){
  18. // console.log(req.headers);
  19. // });
  20. // app.on('checkContinue', function(req, res){
  21. // if ('application/json' == req.headers['content-type']) {
  22. // res.writeContinue();
  23. // console.log('ok');
  24. // res.end('thanks')
  25. // } else {
  26. // res.writeHead(400);
  27. // res.end('bad request, json only');
  28. // }
  29. // });
  30. // app.listen(3000);