Hi

You could simply do a (copy-port ip op) and remove the  content-length and
buffer parts i think.


Le mar. 16 oct. 2018 à 21:17, Chansey <chanse...@gmail.com> a écrit :

>
> Dear all,
>
> I wrote some experiment code for net/http-client.
>
> The purpose is downloading some images from web.
>
> This is my code (run on windows7 using DrRacket, version 6.12):
>
> #lang racket
>
> (require net/http-client)
> (require "./racket-pretty-bytes/main.rkt")
>
> (define ip (let-values (((a b c) (http-sendrecv "www.google.com"
>
> "/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png")))
>
>              c))
>
> ;; different/wrong size per call???
> (define content-length (pipe-content-length ip))
> (println content-length)
>
> (let ([buffer (make-bytes content-length)])
>   (read-bytes! buffer ip 0 content-length)
>   (pretty-print-bytes buffer)
>
>   (let ((op (open-output-file "google.png")))
>     (write buffer op)
>     (close-output-port op))
>   )
>
>
> The problem is the content-length wrong, so the download file
> "google.png" can not be open by image viewer.
>
> Is there any reference code or tutorial for downloading image and save
> files using http-client ?
>
> Thanks.
>
> Br,
> Chansey
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to