New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET(url) gets different results than browser #27

Closed
dtenenba opened this Issue Dec 23, 2012 · 6 comments

Comments

Projects
None yet
4 participants
@dtenenba

dtenenba commented Dec 23, 2012

library(httr)
url <- "http://www.kegg.jp/kegg-bin/show_pathway?eco00260/eco%3ab0002%09%23ff0000,%23ffff00/eco%3ac00263%09%2300ff00,yellow"
GET(url)

results in:

Response [http://www.kegg.jp/kegg-bin/show_pathway?eco00260/eco%3ab0002%09%23ff0000,%23ffff00/eco%3ac00263%09%2300ff00,yellow=NA]
Status: 200
Content-type: text/html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Usage</title>
<link rel="stylesheet" href="/css/kegg2.css" type="text/css">
</head>
<body>
<h3>cannot create 0 (no link ko_kid)type </h3>
</body>
</html>

Whereas if I paste that URL into a browser, I get different (much longer) results.
Am I doing something wrong or is it a bug?
Dan

sessionInfo()
R Under development (unstable) (2012-12-15 r61341)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] httr_0.2

loaded via a namespace (and not attached):
[1] digest_0.6.0 RCurl_1.95-3 stringr_0.6.2 tools_3.0.0

@dtenenba

This comment has been minimized.

dtenenba commented Dec 23, 2012

Looks like the problem is that httr appended "=NA" to the end of the URL. Not sure why....

@hadley

This comment has been minimized.

Member

hadley commented Dec 30, 2012

I'll have to check the spec, but that doesn't look like a valid URL. Httr should behave better though

@rmitchell2301

This comment has been minimized.

rmitchell2301 commented Dec 30, 2012

Thats likely the problem. Looks like everything else was escaped correctly.

From the W3C spec:

The query parameter canonicalization of a string s is the query canonicalization of s, modified as follows:

Replace all instances of the U+0026 AMPERSAND (&) character with %26.

Replace all instances of the U+003D EQUALS SIGN (=) character with %3D.

On Dec 30, 2012, at 12:30 AM, hadley wickham notifications@github.com wrote:

I'll have to check the spec, but that doesn't look like a valid URL. Httr should behave better though


Reply to this email directly or view it on GitHub.

@hadley

This comment has been minimized.

Member

hadley commented Jan 3, 2013

I'll take a look when I'm next working on httr.

@ajdamico

This comment has been minimized.

ajdamico commented Jan 4, 2013

this might be another one.. :) i tried the url he's described with httr and it also returned a different result from chrome and firefox.. http://stackoverflow.com/questions/14148596/retrieving-url-using-rcurl-gives-different-date-format-than-in-browser

@hadley

This comment has been minimized.

Member

hadley commented Nov 29, 2013

Closed in 46c1fe9

@hadley hadley closed this Nov 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment