| Blockland Forums > Modification Help |
| TCPObject GET requests |
| (1/10) > >> |
| Nexus:
I am trying to make a little tcpobject thingy but I'm getting odd results. This is the code I am using: --- Code: ---function Downloader::onDNSResolved(%this) { echo("DNS Resolved"); } function Downloader::onDNSFailed(%this) { echo("DNS Failed"); } function Downloader::onConnected(%this) { echo("Connected"); %req = "GET "@$file@" HTTP/1.0\nHost: "@$ip@"\n\n"; echo(%req); %this.send(%req); } function Downloader::onConnectFailed(%this) { echo("Connection Failed"); } function Downloader::onDisconnect(%this) { echo("Disconnected"); } function Downloader::onLine(%this, %line) { echo("TCP: " @ %line); } if(isobject(Downloader)) Downloader.delete(); new tcpobject(Downloader) --- End code --- I am then putting this in the console: --- Code: ---$ip = "98.227.200.17"; $file = "/shares/USB_Storage/testdoc.txt"; Downloader.connect("98.227.200.17:80"); --- End code --- And it fails to retrieve the file: http://98.227.200.17/shares/USB_Storage/testdoc.txt I tried a similar test using dropbox: http://dl.dropbox.com/u/20459676/BuildBot%20Changelog.txt --- Code: ---$file = "/u/20459676/BuildBot%20Changelog.txt"; $ip = "dl.dropbox.com"; Downloader.connect("dl.dropbox.com:80"); --- End code --- And it worked fine. What is going on here? Is it the difference between how dropbox will simply display the text through the internet if you click the link versus my router will make you download it? |
| Brian Smithers:
new HTTPObject(blah); blah.get("brianhosting.net:80","/index.html"); function blah::onLine(%this,%line) { echo(%line); } worked. FIXED |
| Nexus:
ok so I tried Brian's method and I got a 401 unauthorized. Can anyone else click the link I provided or is it just me that can access it? Also I would still kinda like to know why the TCP was being a bother and how to account for the fact that the url linked to a download request instead of displaying the document. |
| Brian Smithers:
fixed woops |
| Nexus:
--- Quote from: Brian Smithers on March 07, 2012, 06:57:23 PM ---fixed woops --- End quote --- What did you fix? The / before index? I must have not noticed you didn't include that, because I had it anyway. I am still getting a 401 error, can anyone confirm that the link is accessable or not? Edit: it seems that you need a username/password to connect to the ip, but you do not for http://98.227.200.17/shares/ I guess the initial connect request will fail because it needs to connect to the domain before anything else. How can I make it connect to /shares/ ? Now I am trying this: --- Code: ---dlr.get("http://98.227.200.17/shares:80", "/USB_Storage/testdoc.txt"); --- End code --- but it calls onDNSFailed after about a second or two |
| Navigation |
| Message Index |
| Next page |