Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Upload workaround (based on OCMock) #312

Open
ghost opened this issue Jul 11, 2019 · 3 comments
Open

Possible Upload workaround (based on OCMock) #312

ghost opened this issue Jul 11, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 11, 2019

I have been able to implement mock tests for my upload requests based on this Stackoverflow answer.

As a result, I have removed every OHHttpStubs dependency from my project, to not mix libraries. Maybe you could change your internal approach to stubbing the web requests and support upload tasks as well, based on OCMock?

If you do not want to depend on an external library, I think you could implement similar behaviour as OCMock with Method Swizzling.

@jeffctown
Copy link
Collaborator

Hey @Shanakor ! I'm not exactly sure what you're asking for here. Can you please clarify what you need? This library already uses method swizzling.

@ghost
Copy link
Author

ghost commented Jan 27, 2020

I was referring to the "Known Limitations" section in the readme.md (https://github.com/AliSoftware/OHHTTPStubs#known-limitations).

It states that OHHTTPStubs is unable to handle upload requests.

OHHTTPStubs don't simulate data upload. The NSURLProtocolClient @protocol does not provide a way to signal the delegate that data has been sent (only that some has been loaded), so any data in the HTTPBody or HTTPBodyStream of an NSURLRequest, or data provided to -[NSURLSession uploadTaskWithRequest:fromData:]; will be ignored, and more importantly, the -URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: delegate method will never be called when you stub the request using OHHTTPStubs

and

As far as I know, there's nothing we can do about those three limitations. Please let me know if you know a solution that would make that possible anyway.

So, why do you not simply swizzle the methods of classes like NSURLConnection like in the stackoverflow link I posted?

@kirhgoff
Copy link

kirhgoff commented Apr 20, 2023

We also faced the issue with using OHHTTPStubs in out project. We failed to mock the upload request (it hags out until it times out and only then returns mocked data). Looking for a solution for that.

If it is possible with OHHTTPStubs, would appreciate some help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants