From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 2A24C1960004 for ; Wed, 1 Jul 2015 22:24:41 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id A307CB5D86C for ; Wed, 1 Jul 2015 22:50:14 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 5CE0197A836 for ; Wed, 1 Jul 2015 22:50:17 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wp7NgWKnbtLU for ; Wed, 1 Jul 2015 22:50:17 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 39DB197A832 for ; Wed, 1 Jul 2015 22:50:17 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 5EFC4952441 for ; Wed, 1 Jul 2015 22:50:14 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 0E01C1204C4; Wed, 1 Jul 2015 22:50:13 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 74DEA1204B1 for ; Wed, 1 Jul 2015 22:50:09 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=mFs2wlDJw9HpqePbSWZeiAz6mQ0=; b=PN7uyReuT4UDnj/r8m 5y/07CF2hpbkmcfBNCkGV2sINS4dQpE4CCBmb78Z4sW4/Z5UdmYatnYmMCBjYfnr csGqRKwUOQyRKrRKj1WUzanHnmmlFc9x2EDxVvOqf4AlGJGGGsGtFutxfsidY8K1 +Srv0ntPqLleFYz5rRHn7Apg8= Received: by filter0825p1mdw1.sendgrid.net with SMTP id filter0825p1mdw1.20372.5593F00A13 2015-07-01 13:50:02.40842996 +0000 UTC Received: from herokuapp.com (ec2-54-167-212-187.compute-1.amazonaws.com [54.167.212.187]) by ismtpd-041 (SG) with ESMTP id 14e49e1a7ad.1b32.15e2e7e Wed, 01 Jul 2015 13:50:02 +0000 (UTC) Date: Wed, 01 Jul 2015 13:50:02 +0000 From: 0x0dea+redmine@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44428 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11322 X-Redmine-Issue-Author: tbsprs X-Redmine-Issue-Assignee: akr X-Redmine-Sender: 0x0dea X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6OVoOg7L3mpcBy49gIYSeIY8x4sv/8sykdEB vrZRcQuR5rsjDTF2iE6V0zHJo+Ir8YgatAwTwRtzH+SduXh+y7/c0nozzzwYh977+xbbfcmnCjBw0C J9RlUJ0WTVTzhzvP1vDN+G0UP0uUNBMYdMVT X-ML-Name: ruby-core X-Mail-Count: 69831 Subject: [ruby-core:69831] [Ruby trunk - Bug #11322] OpenUri: RuntimeError: HTTP redirection loop X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11322 has been updated by D.E. Akers. The problem is not specific to `OpenURI`: $ curl -L http://apps.london.ca/OpenData/ShapeFiles_Zipped/2010_skateboard_parks_shp.zip curl: (47) Maximum (50) redirects followed It seems the `302 Object Moved` handler on this server has not been properly configured; it expects the previous request to have set a few cookies and simply sends the client back if it doesn't find them. `OpenURI` appears to be incapable of handling such a circumstance, but `Net::HTTP` can and isn't that much more complex. I've presented below a demonstration of how you might go about orchestrating the "handshake" in order to successfully obtain the file. ``` ruby conn = Net::HTTP.new 'apps.london.ca' file = '/OpenData/ShapeFiles_Zipped/2010_skateboard_parks_shp.zip' resp = conn.get file cookie = resp.get_fields('Set-Cookie').map { |c| c.split(';')[0] }.join(';') resp = conn.get file, 'Cookie' => cookie File.write File.basename(file), resp.body ``` ---------------------------------------- Bug #11322: OpenUri: RuntimeError: HTTP redirection loop https://bugs.ruby-lang.org/issues/11322#change-53229 * Author: Tobias Preuss * Status: Open * Priority: Normal * Assignee: Akira Tanaka * ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Trying to download [this file](http://apps.london.ca/OpenData/ShapeFiles_Zipped/2010_skateboard_parks_shp.zip) from [this website](http://www.london.ca/city-hall/open-data/Pages/Open-Data-Data-Catalogue.aspx) with [`OpenUri`](http://ruby-doc.org/stdlib-2.2.2/libdoc/open-uri/rdoc/OpenURI.html) fails with the runtime error "HTTP redirection loop". Here is how I can reproduce the error: ~~~ > require 'open-uri' => true > open('http://apps.london.ca/OpenData/ShapeFiles_Zipped/2010_skateboard_parks_shp.zip') RuntimeError: HTTP redirection loop: http://apps.london.ca/uniquesig87fdc01fb86ce6f0fd235c713015d7d7/uniquesig0/InternalSite/StartApp.asp?resource_id=837A134B9EC24A2197B6AF5745B6CA55&login_type=0&site_name=appstrunk&secure=0&orig_url=http%3a%2f%2fapps.london.ca%2fOpenData%2fShapeFiles_Zipped%2f2010_skateboard_parks_shp.zip from /home/john/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/open-uri.rb:232:in `open_loop' from /home/john/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/open-uri.rb:150:in `open_uri' from /home/john/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/open-uri.rb:716:in `open' from /home/john/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/open-uri.rb:34:in `open' from (irb):2 from /home/john/.rvm/rubies/ruby-2.2.2/bin/irb:11:in `
' ~~~ -- https://bugs.ruby-lang.org/