-
Notifications
You must be signed in to change notification settings - Fork 120
Using the stream outside of the framework #130
Comments
Hi, sorry for late reply. Is this limitation preventing you from implementing some functionality? or is this a style preference? |
Thanks for reply. I was working with methods from org.apache.commons.io.IOUtils (commons-io-2.4) library. A lot of them require an InputStream/Reader parameter. Probably is a style preference that must be addopted by any library that will depend on scalaj-http. More context:
|
I also have similar problem. I think there are few issues here.
I think problem is Request.execute() should not pass non-200 to parser. As it is meant to be one-liner, framework should handle as much logic as it can. And checking error status and throwing exception for all non-success codes seems better choice, than pushing it to parser which has no idea how to interpret contents (as it doesn't know error code). regards, |
Hi Marcin, There's also an |
I'd say that from my perspective it would be just fine if there was a possibility to use library just to send http request, without any further processing. I think it should have something like Request.send() that would give me back plain HttpURLConnection. Now this is handled privately inside exec, and it required me to copy full request sending code in order to use library for chunked response processing. My use of library in the end boils down to: which internally calls some code copied from library, such as: You'll notice - everything is there, I just cannot use it easily :). Good example is HttpResponse class with really nice utilities that would be useful in callback from exec method. You'll even notice HttpResponse signature almost matches parser's signature. marcin |
I have a lot of functions that process streams. One of them would be
InputStreamUtils.copyBigFile(in:InputStreamProvider,out:OutputStreamProvider)
In order to use the current scalaj api my understanding is that I should do something like this:
This doesn't compose well. I would prefer to be able to get an unmanaged InputStream out of the library to use it and close it by myself.
Im thinking of making a pull request with something like https://github.com/yongjunj/scalaj-http/commit/5ecf2946f4f091c5958abf6198c962924ed9c9e7 . Would that be a possible solution? Do you have other suggestions?
Thank you!
The text was updated successfully, but these errors were encountered: