source: Dev/trunk/src/node_modules/request/tests/test-proxy.js @ 484

Last change on this file since 484 was 484, checked in by hendrikvanantwerpen, 11 years ago

Commit node_modules, to make checkouts and builds more deterministic.

File size: 918 bytes
Line 
1var server = require('./server')
2  , events = require('events')
3  , stream = require('stream')
4  , assert = require('assert')
5  , fs = require('fs')
6  , request = require('../index')
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})
Note: See TracBrowser for help on using the repository browser.