Closed namanhams closed 8 years ago
Thx for the issue report, will investigate soon!
Actually thinking about this after a good night's sleep, I don't think I'm gonna need to fix anything, as this works as expected and OHHTTPStubs
already provides another mean to achieve what you want to do:
responseTime
is indeed a simulation of the time it takes to send the request body. It's a way to limit the download speed of the body, so it indeed needs a non-empty body to make senseOHHTTPStubs
also provides requestTime
to simulate the time it would take for your request to be sent/uploaded to the server and processed by the server before the server starts delivering the (possibly empty) response.So to achieve what you're trying to do, you can simply use requestTime
instead!
OHHTTPStubsResponse(data: NSData(), statusCode: statusCode, headers: nil).requestTime(10)
Awesome ! Thanks @AliSoftware . I totally forgot about requestTime
So this won't work:
OHHTTPStubsResponse(data: NSData(), statusCode: statusCode, headers: nil).responseTime(10)
I understand that the sending data will be divided into chunk and sent over the responseTime. So probably that's why when the sending data is empty, responseTime is not used at all.
To work around this, i have to send dumb data :
OHHTTPStubsResponse(data: "abc".dataUsingEncoding(NSUTF8StringEncoding)!, statusCode: statusCode, headers: nil).responseTime(10)