File tree 3 files changed +10
-6
lines changed
3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ methods.forEach(function(method) {
54
54
req . ca ( this . _ca ) ;
55
55
req . cert ( this . _cert ) ;
56
56
req . key ( this . _key ) ;
57
+ if ( this . _host ) {
58
+ req . set ( 'host' , this . _host ) ;
59
+ }
57
60
58
61
req . on ( 'response' , this . _saveCookies . bind ( this ) ) ;
59
62
req . on ( 'redirect' , this . _saveCookies . bind ( this ) ) ;
Original file line number Diff line number Diff line change @@ -27,15 +27,15 @@ module.exports = Test;
27
27
* @api public
28
28
*/
29
29
30
- function Test ( app , method , path , host ) {
30
+ function Test ( app , method , path ) {
31
31
Request . call ( this , method . toUpperCase ( ) , path ) ;
32
32
this . redirects ( 0 ) ;
33
33
this . buffer ( ) ;
34
34
this . app = app ;
35
35
this . _asserts = [ ] ;
36
36
this . url = typeof app === 'string'
37
37
? app + path
38
- : this . serverAddress ( app , path , host ) ;
38
+ : this . serverAddress ( app , path ) ;
39
39
}
40
40
41
41
/**
@@ -53,15 +53,15 @@ Object.setPrototypeOf(Test.prototype, Request.prototype);
53
53
* @api private
54
54
*/
55
55
56
- Test . prototype . serverAddress = function ( app , path , host ) {
56
+ Test . prototype . serverAddress = function ( app , path ) {
57
57
var addr = app . address ( ) ;
58
58
var port ;
59
59
var protocol ;
60
60
61
61
if ( ! addr ) this . _server = app . listen ( 0 ) ;
62
62
port = app . address ( ) . port ;
63
63
protocol = app instanceof https . Server ? 'https' : 'http' ;
64
- return protocol + '://' + ( host || ' 127.0.0.1' ) + ' :' + port + path ;
64
+ return protocol + '://127.0.0.1:' + port + path ;
65
65
} ;
66
66
67
67
/**
Original file line number Diff line number Diff line change @@ -880,14 +880,15 @@ describe('agent.host(host)', function () {
880
880
const agent = request . agent ( app ) ;
881
881
882
882
app . get ( '/' , function ( req , res ) {
883
- res . send ( ) ;
883
+ res . send ( { hostname : req . hostname } ) ;
884
884
} ) ;
885
885
886
886
agent
887
887
. host ( 'something.test' )
888
888
. get ( '/' )
889
889
. end ( function ( err , res ) {
890
- err . hostname . should . equal ( 'something.test' ) ;
890
+ if ( err ) return done ( err ) ;
891
+ res . body . hostname . should . equal ( 'something.test' ) ;
891
892
done ( ) ;
892
893
} ) ;
893
894
} ) ;
You can’t perform that action at this time.
0 commit comments