Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-09-10
12:15 • Closed ticket [3612478fff]: http::geturl follow redirects plus 9 other chang... artifact: 827b32f27f user: kjnash
2013-05-02
11:35 • New ticket [3612478fff]. artifact: 22676a1419 user: oehhar

http::geturl follow redirects

Closed / Duplicate3612478fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 4 years ago
Descriptionplain2013-05-02 11:35:53
IMHO it would be helpful, if http::geturl would follow redirects automatically (or with an option).

Following http://wiki.tcl.tk/1475

Thus 
::http::geturl $url -followredirect 1
would do:
proc geturl_followRedirects {url args} {
     while {1} {
        set token [eval [list http::geturl $url] $args]
        switch -glob [http::ncode $token] {
           30[1237] { ### redirect - see below ### }
           default  { return $token }
        }
        upvar #0 $token state
        array set meta [set ${token}(meta)]
        if {![info exist meta(Location)]} {
           return $token
        }
        set url $meta(Location)
        unset meta
     }
  }

Thank you,
- Harald
kjnashplain2022-09-10 12:15:17
Duplicate of [3102850].  I have copied Harald's comments there and closed this bug.
Log in (anonymous is fine) to add a comment.