Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
/*! | |||
* httpsync - test.js | |||
* Copyright(c) 2012 fengmk2 <fengmk2@gmail.com> | |||
* MIT Licensed | |||
*/ | |||
|
|||
"use strict"; | |||
|
|||
/** | |||
* Module dependencies. | |||
*/ | |||
|
|||
var httpsync = require('../'); | |||
var http = require('http'); | |||
|
|||
var app = http.createServer(function (req, res) { | |||
console.log(req.url, req.headers); | |||
req.on('end', function () { | |||
res.end('hello world'); | |||
}); | |||
}); | |||
|
|||
app.listen(0, function () { | |||
var url = 'http://127.0.0.1:' + app.address().port; | |||
console.log('start to request: ' + url); | |||
var req = httpsync.get(url); | |||
var res = req.end(); | |||
console.log(res); | |||
process.exit(0); | |||
}); |