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 @@ -53,6 +53,9 @@ methods.forEach(function(method) {
53
53
req . ca ( this . _ca ) ;
54
54
req . cert ( this . _cert ) ;
55
55
req . key ( this . _key ) ;
56
+ if ( this . _host ) {
57
+ req . set ( 'host' , this . _host ) ;
58
+ }
56
59
57
60
req . on ( 'response' , this . _saveCookies . bind ( this ) ) ;
58
61
req . on ( 'redirect' , this . _saveCookies . bind ( this ) ) ;
Original file line number Diff line number Diff line change @@ -25,15 +25,15 @@ module.exports = Test;
25
25
* @api public
26
26
*/
27
27
28
- function Test ( app , method , path , host ) {
28
+ function Test ( app , method , path ) {
29
29
Request . call ( this , method . toUpperCase ( ) , path ) ;
30
30
this . redirects ( 0 ) ;
31
31
this . buffer ( ) ;
32
32
this . app = app ;
33
33
this . _asserts = [ ] ;
34
34
this . url = typeof app === 'string'
35
35
? app + path
36
- : this . serverAddress ( app , path , host ) ;
36
+ : this . serverAddress ( app , path ) ;
37
37
}
38
38
39
39
/**
@@ -51,15 +51,15 @@ Object.setPrototypeOf(Test.prototype, Request.prototype);
51
51
* @api private
52
52
*/
53
53
54
- Test . prototype . serverAddress = function ( app , path , host ) {
54
+ Test . prototype . serverAddress = function ( app , path ) {
55
55
var addr = app . address ( ) ;
56
56
var port ;
57
57
var protocol ;
58
58
59
59
if ( ! addr ) this . _server = app . listen ( 0 ) ;
60
60
port = app . address ( ) . port ;
61
61
protocol = app instanceof https . Server ? 'https' : 'http' ;
62
- return protocol + '://' + ( host || ' 127.0.0.1' ) + ' :' + port + path ;
62
+ return protocol + '://127.0.0.1:' + port + path ;
63
63
} ;
64
64
65
65
/**
Original file line number Diff line number Diff line change @@ -866,14 +866,15 @@ describe('agent.host(host)', function () {
866
866
const agent = request . agent ( app ) ;
867
867
868
868
app . get ( '/' , function ( req , res ) {
869
- res . send ( ) ;
869
+ res . send ( { hostname : req . hostname } ) ;
870
870
} ) ;
871
871
872
872
agent
873
873
. host ( 'something.test' )
874
874
. get ( '/' )
875
875
. end ( function ( err , res ) {
876
- err . hostname . should . equal ( 'something.test' ) ;
876
+ if ( err ) return done ( err ) ;
877
+ res . body . hostname . should . equal ( 'something.test' ) ;
877
878
done ( ) ;
878
879
} ) ;
879
880
} ) ;
You can’t perform that action at this time.
0 commit comments