File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,20 @@ export var test_request_shouldFailIfOptionsUrlIsNotDefined = function (done) {
160160 } ) ;
161161} ;
162162
163+ export var test_request_requestShouldTimeout = function ( done ) {
164+ var result ;
165+ http . request ( { url : "http://10.255.255.1" , method : "GET" , timeout : 500 } ) . catch ( function ( e ) {
166+ result = e ;
167+ try {
168+ TKUnit . assert ( result instanceof Error , "Result from request().fail() should be Error! Current type is " + typeof result ) ;
169+ done ( null ) ;
170+ }
171+ catch ( err ) {
172+ done ( err ) ;
173+ }
174+ } ) ;
175+ } ;
176+
163177export var test_request_responseStatusCodeShouldBeDefined = function ( done ) {
164178 var result : http . HttpResponse ;
165179
Original file line number Diff line number Diff line change @@ -32,13 +32,13 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
3232 }
3333 }
3434
35- if ( types . isNumber ( options . timeout ) ) {
36- urlRequest . timeoutInterval = options . timeout * 1000 ;
37- }
38-
3935 if ( types . isString ( options . content ) ) {
4036 urlRequest . HTTPBody = NSString . alloc ( ) . initWithString ( options . content ) . dataUsingEncoding ( 4 ) ;
4137 }
38+
39+ if ( types . isNumber ( options . timeout ) ) {
40+ urlRequest . timeoutInterval = options . timeout / 1000 ;
41+ }
4242
4343 var dataTask = session . dataTaskWithRequestCompletionHandler ( urlRequest ,
4444 function ( data : NSData , response : NSHTTPURLResponse , error : NSError ) {
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ declare module "http" {
7272 content ?: string ;
7373
7474 /**
75- * Gets or sets the request timeout.
75+ * Gets or sets the request timeout in milliseconds .
7676 */
7777 timeout ?: number ;
7878 }
You can’t perform that action at this time.
0 commit comments