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

[NEED A PATCH] My program downloads hosting's 404 page when i try to download non-existent files

Started by Admicos, 18 September 2014 - 05:56 PM
Admicos #1
Posted 18 September 2014 - 07:56 PM
The title explains. When I Try to download nonexistent files, my program downloads 404 page of free hosting.

I TRIED patching. But it doesn't work

Here's my patch

--hostingnamehere 404 patcher START
  local patch = http.get("404 url here")
  if pInfo.readAll() == patch.readAll() then
	error("nil")
  else
  --hostingnamehere 404 patcher END

Note: pInfo is the thing my program downloads.
Note 2: Theres code down below else. So dont worry about it.
Note 3: I use error("nil") because i set the program so it makes a message about nil errors
Win7yes #2
Posted 18 September 2014 - 08:28 PM
Well, they are nonexistent. And all nonexistent stuff in the Internet gets redirected to the host's 404 page. So, trying to download a non existing file will redirect the URL request to the 404 page, meaning that will be the thing that will be downloaded.
Resuming the stuff in simpler words: Do not download non existing files.
Admicos #3
Posted 18 September 2014 - 08:49 PM
Well, they are nonexistent. And all nonexistent stuff in the Internet gets redirected to the host's 404 page. So, trying to download a non existing file will redirect the URL request to the 404 page, meaning that will be the thing that will be downloaded.
Resuming the stuff in simpler words: Do not download non existing files.
Im making a downloader. I dont wanna install nonexistent stuff. But if others want to do. I need something like this or people will get html files on their computer
KingofGamesYami #4
Posted 18 September 2014 - 08:53 PM
If HTML files are the problem, couldn't you just check for "<html>" within the string?
Admicos #5
Posted 18 September 2014 - 09:03 PM
If HTML files are the problem, couldn't you just check for "<html>" within the string?
OMG why i did not try that! I'll try it next day after school thx
Cranium #6
Posted 18 September 2014 - 09:06 PM
You can actually check the http response code with ComputerCraft. Take a look at the HTTP API on the wiki for more details.
Admicos #7
Posted 19 September 2014 - 10:23 AM
If HTML files are the problem, couldn't you just check for "<html>" within the string?
OMG why i did not try that! I'll try it next day after school thx
That worked.
You can actually check the http response code with ComputerCraft. Take a look at the HTTP API on the wiki for more details.
Thanks for that. Maybe ill use it later :)/>