non-ascii card names like Juzám Djinn aren't found with their ascii equivalents (Juzam Djinn)
robdennis opened this issue · 9 comments
This is unlike AEther Vial which does work (returning Æther Vial)
the gatherer website will return Juzám Djinn if you type Juzam Djinn into the text search box
other example is:
http://magiccards.info/cs/en/9.html
$ curl --head --location gatherer.wizards.com/Pages/Card/Details.aspx?name=Juzam%20Djinn
HTTP/1.1 302 Found
Date: Wed, 24 Apr 2013 03:08:00 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: /Pages/Search/Default.aspx?name=+[Juzam Djinn]
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 179
Set-Cookie: BIGipServerWWWNetPool02=2500856074.20480.0000; path=/
HTTP/1.1 302 Found
Date: Wed, 24 Apr 2013 03:08:00 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: /Pages/Card/Details.aspx?multiverseid=159132
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 171
HTTP/1.1 200 OK
Date: Wed, 24 Apr 2013 03:08:00 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 37629
An exact match is not found, Gatherer redirects to /Pages/Search/Default.aspx with the card's name as a query paramater, this matches exactly one card, Gatherer redirects back to /Pages/Card/Details.aspx (now with multiverseid in the query string rather than name).
Tutor doesn't follow redirects since in most cases a redirect indicates that the requested resource does not exist (arguably this is the case here, too). Perhaps the answer is to follow redirects but to return a "404" if the final location is something other than /Pages/Cards/Details.aspx.
Does this commit address your issue, Rob?
Yep, and in such a way that all my stuff 'just works' (tm). Much
appreciated :)
On Wed, Apr 24, 2013 at 1:25 AM, David Chambers notifications@github.comwrote:
Does this commit address your issue, Rob?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/52#issuecomment-16908640
.
actually, just that on Mac OS X it does work great, but swapped into my ubuntu Amazon EC2 box and it seems to block 'forever'
ubuntu@cuesbey:~/tutor$ bin/tutor card 'Juzám Djinn'
Juzám Djinn {2}{B}{B} 5/5 At the beginning of your upkeep, Juzám Djinn deals 1 damage to you.
ubuntu@cuesbey:~/tutor$ bin/tutor card 'Juzam Djinn'
<block till ctr-c>
this is similar to searching for a nonexistent card:
ubuntu@cuesbey:~/tutor$ bin/tutor card 'fake card'
Error: card not found
<block till ctr-c>
curl output looks the same:
ubuntu@cuesbey:~/tutor$ curl --head --location gatherer.wizards.com/Pages/Card/Details.aspx?name=Juzam%20Djinn
HTTP/1.1 302 Found
Date: Wed, 24 Apr 2013 12:59:18 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: /Pages/Search/Default.aspx?name=+[Juzam Djinn]
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 179
Set-Cookie: BIGipServerWWWNetPool02=4178577674.20480.0000; path=/
HTTP/1.1 302 Found
Date: Wed, 24 Apr 2013 12:59:18 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: /Pages/Card/Details.aspx?multiverseid=159132
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 171
HTTP/1.1 200 OK
Date: Wed, 24 Apr 2013 12:59:18 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 37630
edit:
I'll run the tutor unit tests from that machine when I get home from work, since I saw you added for redirects (nice job)
any additional steps I can undertake to troubleshoot?
ubuntu@cuesbey:~/tutor$ make fixtures
ubuntu@cuesbey:~/tutor$ make test
․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
65 tests complete (2 seconds)
ubuntu@cuesbey:~/tutor$ make testcli
․․․․․
5 tests complete (3 seconds)
I guess this means it's a cli-only thing? :(
added some debugging statements:
diff --git a/src/gatherer/card.coffee b/src/gatherer/card.coffee
index 1d00b57..8f03722 100644
--- a/src/gatherer/card.coffee
+++ b/src/gatherer/card.coffee
@@ -9,7 +9,9 @@ module.exports = (details, callback) ->
callback new Error 'invalid which property (valid values are "a" and "b")'
url = gatherer.card.url 'Details.aspx', details
+ console.log('request', url)
request {url}, (err, res, body) ->
+ console.log('response', url)
if err
callback err
else if res.request.uri.pathname isnt '/Pages/Card/Details.aspx'
good search:
ubuntu@cuesbey:~/tutor_other$ bin/tutor card 'juzám djinn'
request http://gatherer.wizards.com/Pages/Card/Details.aspx?name=juz%C3%A1m%20djinn
response http://gatherer.wizards.com/Pages/Card/Details.aspx?name=juz%C3%A1m%20djinn
Juzám Djinn {2}{B}{B} 5/5 At the beginning of your upkeep, Juzám Djinn deals 1 damage to you.
unknown card
Juzám Djinn {2}{B}{B} 5/5 At the beginning of your upkeep, Juzám Djinn deals 1 damage to you.
ubuntu@cuesbey:~/tutor_other$ bin/tutor card 'juzam dl;k;lk;'
request http://gatherer.wizards.com/Pages/Card/Details.aspx?name=juzam%20dl%3Bk%3Blk%3B
response http://gatherer.wizards.com/Pages/Card/Details.aspx?name=juzam%20dl%3Bk%3Blk%3B
Error: card not found
<block for 1min + until ctrl-c>
ubuntu@cuesbey:~/tutor_other$ bin/tutor card 'juzam djinn'
request http://gatherer.wizards.com/Pages/Card/Details.aspx?name=juzam%20djinn
<~30 seconds pass>
TypeError: Cannot read property 'statusCode' of undefined
at Request._callback (/home/ubuntu/tutor_other/lib/gatherer/printings.js:18:14)
at self.callback (/home/ubuntu/tutor_other/node_modules/request/main.js:122:22)
at Request.EventEmitter.emit (events.js:95:17)
at ClientRequest.self.clientErrorHandler (/home/ubuntu/tutor_other/node_modules/request/main.js:225:10)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1484:9)
at Socket.EventEmitter.emit (events.js:117:20)
at net.js:426:14
at process._tickCallback (node.js:415:13)
This is really odd.
yeah, I really don't have a good idea, I don't have access to a different kind of ec2 instance or other kind of ubuntu box at the moment, but I may try to wrestle something up, or at least reproduce this with just node-requests to open a bug there
What's the status of this issue, Rob? I'm happy to merge the fix into master, but not if you think it does more harm than good. :)
I have on my (end of the month) to-do list to figure out if it's a bug with requests itself. I'd hold off merging though because I think for now it's a net-downside.
I'm not blocking on it right now, but I want to figure out why that happens because I do think it would be better if the redirects were followed.
Thanks for checking back on it
On Sun, May 12, 2013 at 4:09 PM, David Chambers notifications@github.com
wrote:
What's the status of this issue, Rob? I'm happy to merge the fix into master, but not if you think it does more harm than good. :)
Reply to this email directly or view it on GitHub:
#52 (comment)