LuaSocket returns nil with http.request

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

LuaSocket returns nil with http.request

Post by Croutonix »

Wiki says LuaSocket is implented in love2d so I tried example code from LuaSocket webpage

Code: Select all

local http=require'socket.http'
body,c,l,h = http.request('http://w3.impa.br/~diego/software/luasocket/http.html')
print('status line',l)
print('body',body)
Returns

Code: Select all

status line     nil
body    nil
I tried multiple examples, I always get nil.
Do I need to allow love in firewall or something like that?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: LuaSocket returns nil with http.request

Post by Positive07 »

Can't replicate with that example, do you have a LÖVE file or something that actually errors?
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: LuaSocket returns nil with http.request

Post by Croutonix »

User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: LuaSocket returns nil with http.request

Post by zorg »

That has the line

Code: Select all

body, c, l, h = http.request("shttp://w3.impa.br/~diego/software/luasocket/http.html")
Never heard of an shttp protocol. :3

Optionally, if that's really not the issue, then i'd suggest not using a fragmentary conf.lua file, since it may affect what modules are loaded and what aren't. (May be wrong on this, but i do remember this being an issue to someone before)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: LuaSocket returns nil with http.request

Post by Croutonix »

Still returns nil with http...
What do you mean by not fragmentary?
I need to add love.conf function to main.lua?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: LuaSocket returns nil with http.request

Post by zorg »

I mean that your love.conf function only sets the console. It's basically missing everything else that's shown on the wiki, though as i said, i might be wrong on this one.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Tjakka5
Party member
Posts: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: LuaSocket returns nil with http.request

Post by Tjakka5 »

If you log 'c' it should tell you which error code you're getting. You can go from there.
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LuaSocket returns nil with http.request

Post by bartbes »

Croutonix wrote: Do I need to allow love in firewall or something like that?
If you have a firewall that's blocking love, that would do it.
zorg wrote:I mean that your love.conf function only sets the console. It's basically missing everything else that's shown on the wiki, though as i said, i might be wrong on this one.
Yeah, that page lists the defaults, you only need to set whatever you're overriding.
Tjakka5 wrote:If you log 'c' it should tell you which error code you're getting. You can go from there.
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
I think it's failing at an earlier state, but according to the luasocket docs...
In case of failure, the function returns nil followed by an error message.
Which would end up in 'c'.
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: LuaSocket returns nil with http.request

Post by Croutonix »

c returns closed, which is not in the list of status codes? What does it mean?
I added it to firewall filter, nothing changed.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: LuaSocket returns nil with http.request

Post by zorg »

May not help much, but i found this: http://stackoverflow.com/questions/2372 ... connection
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests