275 posts
Location
Turkey
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
147 posts
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.
275 posts
Location
Turkey
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
3057 posts
Location
United States of America
Posted 18 September 2014 - 08:53 PM
If HTML files are the problem, couldn't you just check for "<html>" within the string?
275 posts
Location
Turkey
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
3790 posts
Location
Lincoln, Nebraska
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.
275 posts
Location
Turkey
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 :)/>