nealrichardson / httptest

A Test Environment for HTTP Requests in R
https://enpiar.com/r/httptest/
Other
79 stars 10 forks source link

Large HTTP requests fail #7

Closed MarkEdmondson1234 closed 6 years ago

MarkEdmondson1234 commented 7 years ago

Hi Neal, I have used the mock tests as detailed in the other issue, but I get funny errors back when the response is very large. It would be cool to have some guidelines or an error when mocking warning of the limits, or of course no limits if possible.

For an example, I commented out a large response for the googleLanguageR in this line that triggered the errors: https://github.com/MarkEdmondson1234/googleLanguageR/blob/master/tests/testthat/test_unit.R#L53

nealrichardson commented 7 years ago

Here is the limit in the code: https://github.com/nealrichardson/httptest/blob/master/R/mock-api.R#L43-L44

Agree that no limits is desirable and surely doable. The man page for readBin warns against setting too large of a number of bytes to read, but maybe that's overly cautious. I can explore other approaches too. Will do some research and get back to you with a solution one way or another.

nealrichardson commented 7 years ago

That was easier than I expected. Fix is in master here: https://github.com/nealrichardson/httptest/commit/e93c9002efcf526884f34eb5024775c9f4f02d2f#diff-df23c66a2ae0a270a91739db423de906R43

Only adds a couple dozen microseconds to each call, according to some quick microbenchmarking, so not a problem.

Check it out and let me know if it solves your issue.

MarkEdmondson1234 commented 6 years ago

Sorry I didn't get back to you, but yes this was solved

nealrichardson commented 6 years ago

No worries! Figured I would have heard something if it were still a problem.