BlueAmulet/OCEmu

http_patch.lua breaks socket.http with error `socket/http.lua:127: attempt to call local 'create' (a nil value)`

credomane opened this issue · 0 comments

Seems the the /support/http_patch.lua is broken on newer luasocket revisions. My distro recently updated luasocket to the version you can find on this github page or directly at http.lua. OCEmu quit working with the error in the title.

After spending all night and a lunch break on it. I figured it all out shortly after discovering OCemu patches the loaded socket.http.

The fix I employed is this:
Updating line https://github.com/gamax92/OCEmu/blob/82defa8c6bba1089ece327e62db30dbe3168fcdf/src/support/http_patch.lua#L10 to instead of saying create = nil to create = socket.tcp fixed the issue right up. Seems the current luasocket revision expects create to always exist as a function because it never checks that it is actually a function before calling it. A function, btw, which seems to always be socket.tcp. Why they added this extra hop reach socket.tcp I have no idea.