On Fri, 22 Mar 2019, H. Hirzel wrote:
Hello Tobias
On 3/22/19, Tobias Pape Das.Linux@gmx.de wrote:
On 22.03.2019, at 09:35, H. Hirzel hannes.hirzel@gmail.com wrote:
Yes, WebResponse >> #contentStream is there but if I use it I get an error message, see my earlier mail in this thread where I include the details.
It seems that the stream is asked for #reset and that does not go well with the stream WebResponse uses.
SecureSocketStream(Object)>>doesNotUnderstand: #reset
So getting the whole content first and then to ask for a new stream is a workaround. It is a solution but maybe not the solution.
More investigation needed....
No. The WebResponse stream is a non-resettable stream, it comes effectively from the network, so you can't meaningfully #reset it :)
Sure, I am aware that WebResponse is a non-resettable stream.
To reset the SecureSocketStream stream would mean that I have to get the content again from the web. This is not be what is wanted most of the time.
Or you could just pick the right converter based on the mime type of the response. #reset is sent by ImageReadWriter, because it uses trial and error to find the right converter for the image.
Levente
So somewhere we need to
get the content of the WebResponse object
convert it to an in-memory stream.
content asByteArray readStream.
theUrl := 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Squeak-x11.png/617...'.
Form fromBinaryStream: (WebClient httpGet: theUrl) content asByteArray readStream.
I can think of several ways to counter that, but not today :D
Yes, I am interested in this, even in 3 .. 300 days time :-)
in the meantime I use the following patch in my application (method name and class suggested by Marcel) -- a useful solution..
NEW method Form class>>fromUrl: anUrlString
similar to
Form fromFileNamed: fileName
Yours and Marcel's feedback was helpful for me to get at this point.
...................................................................................................................................
'From Squeak5.2 of 13 December 2018 [latest update: #18221] on 22 March 2019 at 11:37:44 am'!
!Form class methodsFor: '*Add-Ons-BaseImage52patches' stamp: 'hjh 3/22/2019 11:37'! fromUrl: anUrlString "It is advisable to call this in a separate process"
self fromBinaryStream: (WebClient httpGet: anUrlString) content asByteArray readStream. ! !
...................................................................................................................................
An issue I had is that depending on the URL this may lock up the image, so it is advisable to put the call to #fromUrl: into another process.
Regards
Hannes