Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ba356d478bb10a1bed724fef310146077d3ee71b125d64880b0a0a074c2fc08c
Ticket: 3102850fffffffffffffffffffffffffffffffff
HTTP does not follow redirects
User & Date: kjnash on 2022-09-10 12:17:07
Changes

  1. closer changed to: "nobody"
  2. comment changed to:
    I am referring to redirects such as the 301 HTTP redirect which is when a page has moved permanently.
    
    At present the http package does not appear to follow such redirects.
    
    This is not the nature of which http was intended to be used and should be fixed accordingly.
    
  3. icomment:
    Bug [3612478] is a duplicate of this one.  I have closed that bug, and copied Harald's comments below:
    (kjnash)
    
    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
    
  4. login: "kjnash"
  5. mimetype: "text/x-fossil-plain"
  6. severity changed to: "Minor"