[squeak-dev] Streaming directly from WebResponse content to
SketchMorph
Casimiro de Almeida Barreto
casimiro.barreto at gmail.com
Thu Oct 18 00:38:31 UTC 2012
On 17-10-2012 20:42, Bert Freudenberg wrote:
> (PNGReadWriter formFromStream: (HTTPClient httpGet: 'http://squeak.org/img/squeaklogosmallerpng')) asMorph openInHand
Not so easy... site requires authentication (hence the idea of using
WebClient...)
| wc url resp ucode passw sm |
Transcript clear.
url := 'http://127.0.0.1:8088/(... lots of path elements ...)/image.png'.
ucode := 'xxx'.
passw := 'yyy'.
resp := (WebClient) new
acceptCookies: true;
username: ucode;
password: passw;
httpGet: url.
resp contentStream binary.
(PNGReadWriter formFromStream: resp contentStream) asMorph openInHand
It fails with "Image format not recognized.
What happens is that in the test there's something like:
understandsImageFormat
#(137 80 78 71 13 10 26 10) do: [ :byte |
stream next = byte ifFalse: [^ false]].
^ true
and while byte is Character stream returns SmallInteger. So, yeah, first
element of list is 137 and first byte of stream is 137 but comparsion
fails. If forced (byte asInteger) it will fail later on decoding.
Interesting enough is that when it reads from a file stream it works
(provided content binary).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20121017/3ecd8240/signature.pgp
More information about the Squeak-dev
mailing list
|