I get a form object if I convert the ByteString object I obtain from the webResponse object by sending #content to a ByteArray object
#asByteArray
| theUrl webResponse | [ theUrl := 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Leopard_%283707288...'.
webResponse := WebClient httpGet: theUrl.
(ImageReadWriter formFromStream: (webResponse content asByteArray readStream)) inspect] fork.
On 3/21/19, H. Hirzel hannes.hirzel@gmail.com wrote:
The following (slighlty adapted) comes up with an error
'image format not recognized'
I put it in another process because today I crashed the image trying out variants of this (infinitive loop somewhere, could not analyze why).
| theUrl | [ theUrl := 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Leopard_%283707288...'.
(ImageReadWriter formFromStream: ((WebClient httpGet: theUrl) content readStream)) inspect] fork.
HH.
On 3/21/19, Tobias Pape Das.Linux@gmx.de wrote:
On 21.03.2019, at 13:14, H. Hirzel hannes.hirzel@gmail.com wrote:
Hello
This thread is related to my question how to get a picture from the web.
I understand that I probably have to use WebClient.
How would one of the convenience methods of WebClient be used to get a picture from the web?
maybe:
ImageReadWriter formFromStream: ((WebClient httpGet: 'the-url') contents readStream)
-t
--Hannes
On 1/18/19, tim Rowledge tim@rowledge.org wrote:
On 2019-01-18, at 1:30 AM, Tobias Pape Das.Linux@gmx.de wrote:
TL;DR: It's just WebClient with differing layers of icing on top.
Hah; so it is. That's good, I guess. Evidently diving a dozen or so layers down wasn't enough to discover that. ;-)
But, yes, it could all be a bit more clear cut.
It certainly could; but more importantly it could do much better for raising and handling errors helpfully. I note with wry amusement how the last part of HTTPSocket class>>#httpGetDocument:args:accept:request: carefully takes the helpful error info of WebClient and ensures that the less helpful HttpSocket response is generated.
And of course none of this alters the fact that a good few methods could do with changing to handle network errors, whichever flavour of WebClient icing they use!
tim
tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Useful random insult:- Proof that evolution CAN go in reverse.