Author Topic: TCPObject GET requests  (Read 2673 times)

Your web server is incorrectly serving MIME types and not recognizing the .txt file as a form of plain text, hence it sends it as a binary stream. Not sure why it's giving you an auth error when I can expect the site just fine and all of it's headers seem to be fine. I'm going to guess that it might have to do with the headers Torque is sending it, possibly the Torque user-agent or lack of it.

I'm pretty sure that it is forcing it to be a download (not incorrectly recognizing anything), instead of displaying html and text files.
When I tried setting up a ftp server it displayed the text in browser correctly, so it is probably intentional that it is a download instead of display.

Can torque seriously not handle download links? How does it fetch files that don't just display?


function TCPObject::get(%this)
{
   //Example of TCPObject.file: /index.html
   //Example of TCPObject.host: blockland.us:80
   %this.send("GET " @ %this.file @ " HTTP/1.1\r\n");
   %this.send("Host: " @ %this.host @ "\r\n");
   %this.send("Content-Location: " @ %this.file @ "\r\n\r\n");
}

topic
idk
this could help
« Last Edit: March 09, 2012, 04:17:39 PM by Brian Smithers »

I'm pretty sure that it is forcing it to be a download (not incorrectly recognizing anything), instead of displaying html and text files.
When I tried setting up a ftp server it displayed the text in browser correctly, so it is probably intentional that it is a download instead of display.

Can torque seriously not handle download links? How does it fetch files that don't just display?
It's something wrong with the MIME type detection. It's not detecting plain text files or it's sending everything as a download (or a octet stream).

It can, the binary buffer thing should have worked. I don't know what's wrong. Try another web server. Or post the exact code you're using to download it.
« Last Edit: March 10, 2012, 05:52:38 AM by Destiny/Zack0Wack0 »

It's something wrong with the MIME type detection. It's not detecting plain text files or it's sending everything as a download (or a octet stream).

It can, the binary buffer thing should have worked. I don't know what's wrong. Try another web server. Or post the exact code you're using to download it.

The code I am using is in the OP, and the httpobject code that is getting just an unauthorized error is identical to brians.  What is a binary buffer?  Am I missing some function that would be getting the information otherwise?  I have seen onbitchunk or something in some programs, but I thought that was a custom function or something.  I'll try to look it up and see if adding it helps.

Dear god, use the search button.

Look at this topic of mine, it is literally the exact same thing as this topic, and it has a solution.
http://forum.blockland.us/index.php?topic=182981.0

Look at Greek's post, it has THE solution to your quesiton.

Dear god, use the search button.

That thread is not a result for any of the following I searched for before posting this:
TCP
TCPObject
TCPObjects
HTTPObjects
TCPObject Downloader
GET Requests
torque downloader
tcpobject header
tcpobject headers

Plus a bunch more in my history

But thanks for linking it

You really shouldn't need to resort to downloading the text file as a binary file. You just make it serve as a text/plain MIME type and then you don't need to do anything, onLine will work fine because it's plain text. The auth error is really weird too.

Code: [Select]
function Downloader::onConnected(%this)
{
      echo("Connected");
      %req = "GET "@$file@" HTTP/1.0\nHost: "@$ip@"\n\n";
      echo(%req);
      %this.send(%req);
}

I'm gonna throw it out there anyway but in the HTTP 1.0 spec you're using for whatever reason, the Host header isn't required and by putting the ip in as the host (incorrect usage) you're almost certainly confusing things. I'd just remove that.

Furthermore lines should be terminated by a CRLF (\r\n) not two line breaks.
« Last Edit: March 13, 2012, 03:27:25 AM by Ephialtes »


I'm gonna throw it out there anyway but in the HTTP 1.0 spec you're using for whatever reason, the Host header isn't required and by putting the ip in as the host (incorrect usage) you're almost certainly confusing things. I'd just remove that.
Provided that the server has virtual hosts enabled, it should stay in there.
(Assuming we're talking about Apache)

You really shouldn't need to resort to downloading the text file as a binary file. You just make it serve as a text/plain MIME type and then you don't need to do anything, onLine will work fine because it's plain text. The auth error is really weird too.
MIME type shouldn't matter as he's parsing the HTTP himself.
« Last Edit: March 15, 2012, 06:22:17 PM by DontCare4Free »


Provided that the server has virtual hosts enabled, it should stay in there.
(Assuming we're talking about Apache)

Not when he's connecting by ip ...

Not when he's connecting by ip ...
I think Apache takes the last or first (don't remember which) vhost if there are no matches or if there is no host header. Can't check right now though.

I can't use apache because I cannot guarantee that my computer will always be on, but my router will be.
I literally just stuck a USB in it and set up its built in data share system.

I am still kinda stumped on it.  I added the downloader::onbinchunk function I was missing, but it isn't getting called.  I tried a million variations on the GET request with all of ephi's suggestions and mixes of them but no matter what I do none of the functions are getting called, except for disconnect after like ten seconds of being idle.

I have tried connecting to other pages the router serves, like http://98.227.200.17/shares
But it seems to not return any data at all.  I am befuddled.
Or maybe it is because the pages are insanely slow to send...
But that problem isn't happening with the files, those send pretty fine

Should I maybe ask on the garagegames forum?

I can't use apache because I cannot guarantee that my computer will always be on, but my router will be.
I literally just stuck a USB in it and set up its built in data share system.

I am still kinda stumped on it.  I added the downloader::onbinchunk function I was missing, but it isn't getting called.  I tried a million variations on the GET request with all of ephi's suggestions and mixes of them but no matter what I do none of the functions are getting called, except for disconnect after like ten seconds of being idle.

I have tried connecting to other pages the router serves, like http://98.227.200.17/shares
But it seems to not return any data at all.  I am befuddled.
Or maybe it is because the pages are insanely slow to send...
But that problem isn't happening with the files, those send pretty fine

Should I maybe ask on the garagegames forum?
Just upload it to Dropbox...?