initial commit
[JIRC.git] / node_modules / request / tests / test-proxy.js
CommitLineData
39c8b14f 1var server = require('./server')
2 , events = require('events')
3 , stream = require('stream')
4 , assert = require('assert')
5 , fs = require('fs')
6 , request = require('../main.js')
7 , path = require('path')
8 , util = require('util')
9 ;
10
11var port = 6768
12 , called = false
13 , proxiedHost = 'google.com'
14 ;
15
16var s = server.createServer(port)
17s.listen(port, function () {
18 s.on('http://google.com/', function (req, res) {
19 called = true
20 assert.equal(req.headers.host, proxiedHost)
21 res.writeHeader(200)
22 res.end()
23 })
24 request ({
25 url: 'http://'+proxiedHost,
26 proxy: 'http://localhost:'+port
27 /*
28 //should behave as if these arguments where passed:
29 url: 'http://localhost:'+port,
30 headers: {host: proxiedHost}
31 //*/
32 }, function (err, res, body) {
33 s.close()
34 })
35})
36
37process.on('exit', function () {
38 assert.ok(called, 'the request must be made to the proxy server')
39})