Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP URL redirection now works with Stata 13

    Dear Statalisters, all of a sudden I've just stumbled on the URL redirection finally supported in Stata 13.0 (but not in Stata 12). This is something I had requested back in 2008.
    Not sure if it has been described in the changes anywhere (couldn't find it being mentioned, or even intentional).

    In older versions of Stata you get an error if the server decides to redirect the request:
    Click image for larger version

Name:	stata_redir12.png
Views:	1
Size:	9.4 KB
ID:	31623

    Now you do get the proper file:
    Click image for larger version

Name:	stata_redir13.png
Views:	1
Size:	2.4 KB
ID:	31624

    This seems to be a more reasonable behavior.

    Thank you, Sergiy Radyakin.
    Last edited by Sergiy Radyakin; 23 Jun 2014, 21:46. Reason: Changed tags

  • #2
    This is good but I wish it went further. A year or so ago Notre Dame decided we would all be much happier if our URLs started with www3 rather than www. That screwed up a lot of my example code and still screws it up, e.g.

    Code:
    . use http://www.nd.edu/~rwilliam/statafiles/reg01.dta, clear
    file http://www.nd.edu/~rwilliam/statafiles/reg01.dta not found
    server says file permanently redirected to http://www3.nd.edu/~rwilliam/statafiles/reg01.dta
    r(601);
    
    . use http://www3.nd.edu/~rwilliam/statafiles/reg01.dta, clear
    I suppose there is some great security concern here but it is still mildly annoying.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Dear Richard,

      I think the problem is not really www3 vs www, but the difference in the server response code. In my example above, the response code is 307 (temporary redirect), in your case it is 301 (moved permanently). The difference is that the 307 is only a maintenance code, saying for now the requested resource can be obtained from an alternative location (for whatever reason, for example authorized and non-authorized users get different content, users from different regions get different content, load balancing between the servers, you name it). In your case the resource has moved, permanently, it is no longer available at this url, you should be using the alternative url, which is provided to you by the server. So just update your codes.

      Different software decide for themselves how to treat the response codes. This is how e.g. the ever popular Total Commander handles it:
      Code:
      Connect to: (06/24/2014 11:23:20)
      hostname=www.nd.edu
      www.nd.edu=54.243.157.38
      Connect
      GET /~rwilliam/statafiles/reg01.dta HTTP/1.0
      Host: www.nd.edu
      User-Agent: Mozilla/4.0 (compatible; Totalcmd; XWHATEVEROSX)
      Connection: close
      
      HTTP/1.1 301 Moved Permanently
      Location: http://www3.nd.edu/~rwilliam/statafiles/reg01.dta
      ----------
      Connect to: (06/24/2014 11:23:20)
      hostname=www3.nd.edu
      www3.nd.edu=129.74.12.151
      Connect
      GET /~rwilliam/statafiles/reg01.dta HTTP/1.0
      Host: www3.nd.edu
      User-Agent: Mozilla/4.0 (compatible; Totalcmd; XWHATEVEROSX)
      Connection: close
      
      HTTP/1.1 200 OK
      Copied (06/24/2014 11:23:20): http://www3.nd.edu/~rwilliam/statafiles/reg01.dta -> c:\Users\XWHATEVERUSERX\Desktop\reg01.dta 980 bytes
      In any case I still wish we could get the http response code programmatically, as well as, perhaps, get a warning on 307 just for logging and protocol purposes.

      Best regards, Sergiy Radyakin

      Comment

      Working...
      X