PageRenderTime 40ms CodeModel.GetById 37ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 1ms

/extra/images/http/http.factor

http://github.com/abeaumont/factor
Unknown | 22 lines | 17 code | 5 blank | 0 comment | 0 complexity | cd2a030e9586143ea51accbb7a205b19 MD5 | raw file
 1! Copyright (C) 2009 Doug Coleman.
 2! See http://factorcode.org/license.txt for BSD license.
 3USING: accessors assocs http.client images.loader
 4images.loader.private images.viewer io.pathnames kernel
 5namespaces present sequences ;
 6IN: images.http
 7
 8<PRIVATE
 9
10: content-type ( response -- type/f )
11    content-type>> dup "image/" head?
12    [ 6 tail ] [ drop f ] if ;
13
14PRIVATE>
15
16: load-http-image ( path -- image )
17    [ http-get swap content-type ]
18    [ present file-extension ] bi or
19    (image-class) load-image* ;
20
21: http-image. ( path -- )
22    load-http-image image. ;