[squeak-dev] Modern way to load a picture from the web?

H. Hirzel hannes.hirzel at gmail.com
Fri Mar 22 08:35:58 UTC 2019


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....

HH


On 3/22/19, Marcel Taeumel <marcel.taeumel at hpi.de> wrote:
> Huh? WebResponse >> #contentStream has been there since 2012.
>
> Best,
> Marcel
> Am 21.03.2019 20:37:40 schrieb H. Hirzel <hannes.hirzel at gmail.com>:
> It works if I replace
>
> #contentStream
>
> with
>
> content asByteArray readStream
>
> Form fromBinaryStream: (WebClient httpGet:
> 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Squeak-x11.png/617px-Squeak-x11.png')
> content asByteArray readStream.
>
> On 3/21/19, H. Hirzel wrote:
>> Thanks for answering, Marcel
>>
>> On 3/21/19, Marcel Taeumel wrote:
>>> What about ...
>>>
>>> Form fromBinaryStream: (WebClient httpGet:
>>> 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Squeak-x11.png/617px-Squeak-x11.png')
>>> contentStream.
>>
>> Unfortunately a debugger window comes up [1]
>>
>>
>>> ... I think we should add a #fromUrl: besides Form class >>
>>> #fromFileNamed:
>>> and there distinguish between file paths and HTTP urls etc:
>>>
>>> Form fromUrl:
>>> 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Squeak-x11.png/617px-Squeak-x11.png'.
>>
>> Yes, that would be fine to create a new convenience method
>>
>> Form fromUrl:
>>
>> after we have figured out the solution.
>>
>> -- Hannes
>>
>> [1]
>> SecureSocketStream(Object)>>doesNotUnderstand: #reset
>> Receiver: SecureSocketStream[inbuf:4kb/outbuf:4kb]
>> Arguments and temporary variables:
>> aMessage: reset
>> exception: MessageNotUnderstood: SecureSocketStream>>reset
>> resumeValue: nil
>> Receiver's instance variables:
>> recentlyRead: 0
>> socket: a Socket[destroyed]
>> inBuffer: #[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0...etc...
>> outBuffer: #[71 69 84 32 47 119 105 107 105 112 101 100 105 97 47
>> 99 111 109 10...etc...
>> inNextToWrite: 1
>> outNextToWrite: 1
>> lastRead: 0
>> timeout: 45
>> autoFlush: true
>> bufferSize: 4096
>> binary: true
>> shouldSignal: true
>> ssl: nil
>> sendBuf: #[23 3 3 0 232 61 247 6 24 144 238 146 249 51 100 82 127
>> 29 104 195 17...etc...
>> readBuf: #[203 4 102 97 151 46 237 173 196 165 168 136 21 56 21 225
>> 6 113 183 1...etc...
>> decoded: a ReadStream
>> certIssues: 0
>>
>> [] in ImageReadWriter class>>formFromStream:
>> Receiver: ImageReadWriter
>> Arguments and temporary variables:
>>
>> Receiver's instance variables:
>> superclass: Object
>> methodDict: a MethodDictionary(#atEnd->(ImageReadWriter>>#atEnd "a
>> CompiledMethod...etc...
>> format: 65537
>> instanceVariables: #('stream')
>> organization: ('accessing' nextImage nextPutImage:)
>> ('stream access' atEnd close...etc...
>> subclasses: {PCXReadWriter . XBMReadWriter . JPEGReadWriter .
>> JPEGReadWriter2 ....etc...
>> name: #ImageReadWriter
>> classPool: a Dictionary(#ImageNotStoredSignal->nil
>> #MagicNumberErrorSignal->nil...etc...
>> sharedPools: nil
>> environment: nil
>> category: #'Graphics-Files'
>>
>
>


More information about the Squeak-dev mailing list