awaddell
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2011
09:53 PM
bug with AsyncHead ?
It seems that AsyncHead may be returning the wrong response code in the scenario below where a URL redirects to AWS S3. Curl responds with 302, which matches the Status header, but Roku (2.9 <<correction 3.0 build 2206>> :!: ) seems to return 403 even though the status header shows 302.
Sub AsyncHeadTest()
' curl -X HEAD -v http://posterous.com/getfile/files.post ... ne_161.jpg
' * About to connect() to posterous.com port 80 (#0)
' * Trying 184.106.20.99... connected
' * Connected to posterous.com (184.106.20.99) port 80 (#0)
' > HEAD /getfile/files.posterous.com/ggmiller/hupoWXCzTYANdgdA5jwUwcZ9VPENsteT4H1TGTnyN44QSbFWWGGidVQ0Ylls/ystone_161.jpg HTTP/1.1
' > User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
' > Host: posterous.com
' > Accept: */*
' >
' < HTTP/1.1 302 Found
' < Server: nginx/0.7.65
' < Date: Thu, 23 Jun 2011 04:00:14 GMT
' < Content-Type: text/html
' < Connection: close
' < Status: 302 Found
' < Location: http://s3.amazonaws.com/files.posterous ... nnmpjus%3D
' < Content-Length: 0
' <
' * Closing connection #0
transfer = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
print "Transfer identity:" + Stri(transfer.GetIdentity())
transfer.SetPort(port)
transfer.SetUrl("http://posterous.com/getfile/files.posterous.com/ggmiller/hupoWXCzTYANdgdA5jwUwcZ9VPENsteT4H1TGTnyN44QSbFWWGGidVQ0Ylls/ystone_161.jpg")
transfer.AsyncHead()
msg = wait(0, port)
if type(msg) = "roUrlEvent" then
code = msg.GetResponseCode()
print "HTTP Response Code: " + Stri(code)
print "Identity:" + Stri(msg.GetSourceIdentity())
headers = msg.GetResponseHeaders()
for each header in headers
print header + ":" + headers[header]
next
end if
'Transfer identity: 957483920
'HTTP Response Code: 403
'Identity: 957483920
'connection:close
'location:http://s3.amazonaws.com/files.posterous.com/ggmiller/hupoWXCzTYANdgdA5jwUwcZ9VPENsteT4H1TGTnyN44QSbFWWGGidVQ0Ylls/ystone_161.jpg?AWSAccessKeyId=AKIAJFZAE65UYRT34AOQ&Expires=1308804634&Signature=7Ln8iFYrOu992vVKupNNVQAmgzc%3D
'status:302 Found
'date:Thu, 23 Jun 2011 04:45:34 GMT
'content-length:0
'content-type:text/html
'server:nginx/0.7.65
End Sub
Sub AsyncHeadTest()
' curl -X HEAD -v http://posterous.com/getfile/files.post ... ne_161.jpg
' * About to connect() to posterous.com port 80 (#0)
' * Trying 184.106.20.99... connected
' * Connected to posterous.com (184.106.20.99) port 80 (#0)
' > HEAD /getfile/files.posterous.com/ggmiller/hupoWXCzTYANdgdA5jwUwcZ9VPENsteT4H1TGTnyN44QSbFWWGGidVQ0Ylls/ystone_161.jpg HTTP/1.1
' > User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
' > Host: posterous.com
' > Accept: */*
' >
' < HTTP/1.1 302 Found
' < Server: nginx/0.7.65
' < Date: Thu, 23 Jun 2011 04:00:14 GMT
' < Content-Type: text/html
' < Connection: close
' < Status: 302 Found
' < Location: http://s3.amazonaws.com/files.posterous ... nnmpjus%3D
' < Content-Length: 0
' <
' * Closing connection #0
transfer = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
print "Transfer identity:" + Stri(transfer.GetIdentity())
transfer.SetPort(port)
transfer.SetUrl("http://posterous.com/getfile/files.posterous.com/ggmiller/hupoWXCzTYANdgdA5jwUwcZ9VPENsteT4H1TGTnyN44QSbFWWGGidVQ0Ylls/ystone_161.jpg")
transfer.AsyncHead()
msg = wait(0, port)
if type(msg) = "roUrlEvent" then
code = msg.GetResponseCode()
print "HTTP Response Code: " + Stri(code)
print "Identity:" + Stri(msg.GetSourceIdentity())
headers = msg.GetResponseHeaders()
for each header in headers
print header + ":" + headers[header]
next
end if
'Transfer identity: 957483920
'HTTP Response Code: 403
'Identity: 957483920
'connection:close
'location:http://s3.amazonaws.com/files.posterous.com/ggmiller/hupoWXCzTYANdgdA5jwUwcZ9VPENsteT4H1TGTnyN44QSbFWWGGidVQ0Ylls/ystone_161.jpg?AWSAccessKeyId=AKIAJFZAE65UYRT34AOQ&Expires=1308804634&Signature=7Ln8iFYrOu992vVKupNNVQAmgzc%3D
'status:302 Found
'date:Thu, 23 Jun 2011 04:45:34 GMT
'content-length:0
'content-type:text/html
'server:nginx/0.7.65
End Sub
4 REPLIES 4
awaddell
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2011
07:53 PM
Re: bug with AsyncHead ?
Actually, by box is running 3.0, build 2206.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2011
08:29 PM
Re: bug with AsyncHead ?
AWS is returning the 403 when it gets the HEAD request forwarded from the 302. Do a straight HEAD request on the AWS url and you'll see where it's happening. Looks like AWS doesn't like HEADs for some reason.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
awaddell
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2011
11:24 AM
Re: bug with AsyncHead ?
Thanks for the reply, but doesn't the response from curl indicating that AWS is handling the HEAD request as expected? In other words, shouldn't curl -X HEAD and AysncHead return the same code regardless of how the remote server behaves?

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2011
11:40 AM
Re: bug with AsyncHead ?
The 302 is a redirect. It's telling the client to go to the Location: address to get the real content. The Roku is following the redirect and returning the headers for the actual content, not the redirect headers. It's perhaps arguable which is "better", but in almost all cases the client cares about the headers for the actual content and not any intermediate redirect headers that happen to be encountered on the way to reaching the content.
--Mark
--Mark