1 ! Copyright (C) 2015 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
4 USING: accessors http http.client http.client.private kernel
10 5 max-redirects set-global
16 : http-head-no-redirects ( url -- response data )
17 <head-request> 0 >>redirects http-request* ;
19 : next-url ( url -- next-url redirected? )
21 redirects get max-redirects get <= [
22 dup http-head-no-redirects drop
24 nip "location" header t
26 ] [ too-many-redirects ] if ;
30 : long-url ( short-url -- long-url )
31 [ [ next-url ] loop ] with-scope ;