I tried to do something with sockets in FBA, and successfully had access to my email via pop3 and smtp.
Now I try to get some plain text using sockets and HTTP.
Code:
local zx=10
local sock=socket.tcp()
local finalStr = "Establishing connection.."
-- connect to a webserver
sock:settimeout(25)
sock:connect("www.helvi.su", 80)
sock:send("GET /tiny/result HTTP/1.0\r\n")
sock:send("Host: helvi.su\r\n\r\n")
function onmainloop()
print(10,zx, finalStr,255,0,0)
data,err = sock:receive()
if data ~= nil then
finalStr=data
zx=zx+10
end
end
function onstylusdown(x,y)
quit()
end
function onquit()
sock:close()
end
My code (you see, it's based on example 21) gives to me only headers of page:
Code:
Establishing connection..
HTTP/1.1 200 OK
Date: Thu, 24 Jun 2010 17:46:30 GMT
Server: Apache/2.2.14 (Unix)
Last-Modified: Thu, 24 Jun 2010 17:41:18 GMT
ETag: "845e6176-d-489ca296fb07b"
Accept-Ranges: bytes
Content-Length: 13
Connection: close
Content-Type: text/plain
But when I use telnet:
Code:
>>GET /tiny/result HTTP/1.0
>>Host: helvi.su
>>
<<HTTP/1.1 200 OK
<<Date: Thu, 24 Jun 2010 17:46:30 GMT
<<Server: Apache/2.2.14 (Unix)
<<Last-Modified: Thu, 24 Jun 2010 17:41:18 GMT
<<ETag: "845e6176-d-489ca296fb07b"
<<Accept-Ranges: bytes
<<Content-Length: 13
<<Connection: close
<<Content-Type: text/plain
<<
<<file created.
"file created" - it's content of file
http://helvi.su/tiny/resultWhat's wrong?

Help me please ^_^