This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
doublequestionmark's profile picture

Does Http.get Support PHP Redirects

Started by doublequestionmark, 30 July 2014 - 11:47 PM
doublequestionmark #1
Posted 31 July 2014 - 01:47 AM
Does Http.Get Support PHP Redirects?
For Example I Want A Computer To Download "File.png" Using http.get("http://example.com/redirect.php") And In The PHP File Would Be

<?php
   header( 'Location: http://example.com/File.png' ) ;
?>
Will It Work?
theoriginalbit #2
Posted 31 July 2014 - 01:56 AM
I could be wrong, but I'm pretty sure it doesn't, in the Java class ComputerCraft uses, in order to follow redirects you must set a flag to true, and I don't think dan has done that. you could easily test this, take a look at what the output is from the request, if it's empty then you know it's not worked.

if it doesn't work, the way around this is to have your PHP script open the image, set the header to specify an image is being delivered, and dump the image out.
doublequestionmark #3
Posted 31 July 2014 - 02:12 AM
The Output From The Request Was: Table: 0x24c196c8
It Should Have Been cow go moo
Any Ideas?
theoriginalbit #4
Posted 31 July 2014 - 02:16 AM
okay, so you're not familiar with the HTTP API. Take a look at the return value from http.get and you'll see why you got a table.
doublequestionmark #5
Posted 31 July 2014 - 02:22 AM
Thank You, I Forgot The .readAll() It's Been So Long.
But It Looks Like The PHP Redirect Is Working So I Thank You.

btw If Anyone Wants To Lock This Post They Can