Forums » Community Projects

[LUA] httplib - HTTP Library

Dec 11, 2007 firsm link
Hey there,

I have rewritten my old lua http library, for anyone interested:

http://sandbox.0x0b.de/httplib.zip

Regards,
firsm
Dec 11, 2007 ThinkHen link
Ah, thank you for this. My dream of ingame guild web pages is finally coming true...

-Nautargos
Dec 12, 2007 drazed link
very nice =)

Thanks firsm, I look forward to playing with this soon(tm).
Dec 21, 2007 sunsetbill link
Sweet! Thank you, firsm.
Dec 21, 2007 slime73 link
Yes, awesome. Easy to make an iTunes controller for my mac now. :)
Dec 23, 2007 slime73 link
How would I go about doing something such as, say, posting something to the Vendetta forums using the HTTP library?
Dec 24, 2007 firsm link
test from the httplib
Dec 24, 2007 firsm link
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.
Dec 25, 2007 Lord~spidey link
Code=Lies
Dec 25, 2007 k776 link
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?
Dec 27, 2007 a1k0n link
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.
Dec 27, 2007 blacknet link
501 badgateway is the ugly WSAEWOULDBLOCK.

The problem is NO DATA IS SENT to the server. the connect was NEVER attempted.

Ed