AliSoftware / OHHTTPStubs

Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
MIT License
5.04k stars 601 forks source link

responseTime doesn't work if the sending data is empty #177

Closed namanhams closed 8 years ago

namanhams commented 8 years ago

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)

AliSoftware commented 8 years ago

Thx for the issue report, will investigate soon!

AliSoftware commented 8 years ago

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:

So to achieve what you're trying to do, you can simply use requestTime instead!

OHHTTPStubsResponse(data: NSData(), statusCode: statusCode, headers: nil).requestTime(10) 
namanhams commented 8 years ago

Awesome ! Thanks @AliSoftware . I totally forgot about requestTime