Permalink
Browse files

Add test for proxy option

  • Loading branch information...
dominictarr committed Nov 17, 2011
1 parent 43cd887 commit 841664e309f329be98c1a011c634f5291af1eebc
Showing with 40 additions and 0 deletions.
  1. +40 −0 tests/test-proxy.js
View
@@ -0,0 +1,40 @@
+var server = require('./server')
+ , events = require('events')
+ , stream = require('stream')
+ , assert = require('assert')
+ , fs = require('fs')
+ , request = require('../main.js')
+ , path = require('path')
+ , util = require('util')
+ ;
+
+var port = 6768
+ , called = false
+ , proxiedHost = 'google.com'
+ ;
+
+var s = server.createServer(port)
+s.listen(port, function () {
+ s.on('/', function (req, res) {
+ called = true
+ assert.equal(req.headers.host, proxiedHost)
+ res.writeHeader(200)
+ res.end()
+ })
+ console.error('oaneuth')
+ request ({
+ url: 'http://'+proxiedHost,
+ proxy: 'http://localhost:'+port
+ /*
+ //should behave as if these arguments where passed:
+ url: 'http://localhost:'+port,
+ headers: {host: proxiedHost}
+ //*/
+ }, function (err, res, body) {
+ s.close()
+ })
+})
+
+process.on('exit', function () {
+ assert.ok(called, 'the request must be made to the proxy server')
+})

0 comments on commit 841664e

Please sign in to comment.