Forums » Community Projects
[LUA] httplib - HTTP Library
Hey there,
I have rewritten my old lua http library, for anyone interested:
http://sandbox.0x0b.de/httplib.zip
Regards,
firsm
I have rewritten my old lua http library, for anyone interested:
http://sandbox.0x0b.de/httplib.zip
Regards,
firsm
Ah, thank you for this. My dream of ingame guild web pages is finally coming true...
-Nautargos
-Nautargos
very nice =)
Thanks firsm, I look forward to playing with this soon(tm).
Thanks firsm, I look forward to playing with this soon(tm).
Sweet! Thank you, firsm.
Yes, awesome. Easy to make an iTunes controller for my mac now. :)
How would I go about doing something such as, say, posting something to the Vendetta forums using the HTTP library?
test from the httplib
I posted an example (5): http://code.fahi.eu/trac/wiki/docs/httplib
please note that when you used www.vendetta-online.com for grabing your cookies, you do have to use the very same domain when posting stuff to the forum. When you get a cookie from vendetta-online.com, the lib won't send it back to www.vendetta-online.com and vice versa.
please note that when you used www.vendetta-online.com for grabing your cookies, you do have to use the very same domain when posting stuff to the forum. When you get a cookie from vendetta-online.com, the lib won't send it back to www.vendetta-online.com and vice versa.
Code=Lies
There seems to a problem when using multiple connects in one script, one within a loop, and getting a response from the one outside the loop. I'm constantly getting 501 - Bad Gateway when I manually submit commands, then if I submit it right after that again, no problems. The script is somewhat like this (not proper lua :P )
function bleh()
local http_send = HTTP.new()
http_send.POST.add('data', data)
http_send.method = 'POST'
http_send.urlopen('url')
wait 30 seconds
bleh()
end
function blah
local http_get = HTTP.new()
http_get.POST.add('data', data)
http_get.method = 'POST'
local function mycb(response)
if (response.status == 200) then
print(response.body.get())
else
print(response.status .. ' - ' .. response.statusmsg)
end
end
http_get.urlopen('url', mycb)
end
RegisterEvent(bleh, "PLAYER_ENTERED_GAME")
registerCommand("blah", function () blah() end)
It starts bleh on login, then waits for /blah every so often. Bleh starts up fine, and works. But the moment I type /blah I get the 501. Type /blah again, goes through no problems.
I've run data integrity checks, everything is fine, no lua errors, so I come to you. Is there something I'm mission (I thought maybe the fact that it overrides any existing HTTP connection, but different variables don't help :(
Is there a fix, or work around for this?
function bleh()
local http_send = HTTP.new()
http_send.POST.add('data', data)
http_send.method = 'POST'
http_send.urlopen('url')
wait 30 seconds
bleh()
end
function blah
local http_get = HTTP.new()
http_get.POST.add('data', data)
http_get.method = 'POST'
local function mycb(response)
if (response.status == 200) then
print(response.body.get())
else
print(response.status .. ' - ' .. response.statusmsg)
end
end
http_get.urlopen('url', mycb)
end
RegisterEvent(bleh, "PLAYER_ENTERED_GAME")
registerCommand("blah", function () blah() end)
It starts bleh on login, then waits for /blah every so often. Bleh starts up fine, and works. But the moment I type /blah I get the 501. Type /blah again, goes through no problems.
I've run data integrity checks, everything is fine, no lua errors, so I come to you. Is there something I'm mission (I thought maybe the fact that it overrides any existing HTTP connection, but different variables don't help :(
Is there a fix, or work around for this?
The 501 Bad Gateway is generated by firsm's code when the connection fails... it's probably a problem with the underlying socket code in VO. Are you using Windows? WinSock does non-blocking connections slightly differently (wrong IMO) and I don't know if that's handled correctly. BlackNet was having a similar problem.
Nice work, by the way, firsm. HTTP is a simple protocol, until you have to deal with all the annoying intricacies in practice.
Nice work, by the way, firsm. HTTP is a simple protocol, until you have to deal with all the annoying intricacies in practice.
501 badgateway is the ugly WSAEWOULDBLOCK.
The problem is NO DATA IS SENT to the server. the connect was NEVER attempted.
Ed
The problem is NO DATA IS SENT to the server. the connect was NEVER attempted.
Ed