Jump to content




Does Http.get Support PHP Redirects


  • You cannot reply to this topic
4 replies to this topic

#1 doublequestionmark

  • Members
  • 118 posts
  • LocationI honestly don't know

Posted 31 July 2014 - 12: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?

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 31 July 2014 - 12: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.

#3 doublequestionmark

  • Members
  • 118 posts
  • LocationI honestly don't know

Posted 31 July 2014 - 01:12 AM

The Output From The Request Was: Table: 0x24c196c8
It Should Have Been cow go moo
Any Ideas?

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 31 July 2014 - 01: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.

#5 doublequestionmark

  • Members
  • 118 posts
  • LocationI honestly don't know

Posted 31 July 2014 - 01: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





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users