HTTPS

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Enno
Prole
Posts: 8
Joined: Tue Mar 17, 2015 1:10 pm

HTTPS

Post by Enno »

I've been away for a while but have an idea for a project that requires calling an API over a TLS connection.

I found the wiki page on lua-https, and it mentions that this will be part of Love 12.0, but that's probably still some time out? Is there a nightly build of 12.0 that already includes this?

I see that it should be possible to compile it myself for use with earlier versions, but that's historically not gone so we'll for me. Can someone who has done this send me their binary of https.dll for Love 11.4? That would be super. If not, then I'll probably give compiling it myself a shot over the holidays.
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: HTTPS

Post by EngineerSmith »

Github actions is where all the builds are kept, you'd need a github account to access them: https://github.com/love2d/love/actions/runs/2083673514

Just scroll down to the artefacts and use what you need. Love 12.0 changes somethings like stencils and other graphics elements to do with meshes. As there is no wiki on this, so you will need to look into the source to see how to use these new changes. changes.txt include everything that's changed
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: HTTPS

Post by slime »

lua-https is integrated into the love dll, in love 12. But we also have separate builds of a standalone dll for it, via github actions in the lua-https repository: https://github.com/love2d/lua-https/act ... #artifacts
User avatar
Enno
Prole
Posts: 8
Joined: Tue Mar 17, 2015 1:10 pm

Re: HTTPS

Post by Enno »

These are both great answers, thank you much!
User avatar
Enno
Prole
Posts: 8
Joined: Tue Mar 17, 2015 1:10 pm

Re: HTTPS

Post by Enno »

With either solution, I'm getting the same error when trying to use query parameters:

Code: Select all

code, body, headers = https.request('https://api.ipify.org?format=json', {})
returns a code of 0. Without the query parameters,

Code: Select all

code, body, headers = https.request('https://api.ipify.org', {})
returns 200 and a body. I didn't see any examples with query parameters, and the documentation doesn't say they need to be treated specially, but I must me doing something wrong. What is it?
User avatar
Enno
Prole
Posts: 8
Joined: Tue Mar 17, 2015 1:10 pm

Re: HTTPS

Post by Enno »

Never mind, I found it: If I add a slash to the end of the path, things work fine, I'll just use https://api.ipify.org/?format=json
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: HTTPS

Post by ivan »

Looking forward to HTTPS and version 12.
Great job to everybody involved in the love2d development community!
wolf
Prole
Posts: 14
Joined: Tue Jan 12, 2021 10:24 am

Re: HTTPS

Post by wolf »

Sorry for necro-ing an old topic, but I have a question regarding HTTPS stuff with this library that is part of LÖVE 12.

I already build LÖVE 12 on my local machine and HTTPS get requests (the default) all work fine.

How would I do a POST request using this library? Can I find documentation anywhere for this library?
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: HTTPS

Post by ReFreezed »

I believe the interface is the same as socket.http, so just provide a body for the request after the url string argument to do a POST.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
wolf
Prole
Posts: 14
Joined: Tue Jan 12, 2021 10:24 am

Re: HTTPS

Post by wolf »

Thanks ReFreezed, that works.

I also found a gist with the following code, which works fine:

Code: Select all

local https = require "https"

do
	local code, body = https.request("https://example.com")
	assert(code == 200, body)
end

do
	local code, body, headers = https.request("http://example.com", {method = "post", headers = {}, data = "cake"})
	assert(code == 200 and headers, body)

	for i, v in pairs(headers) do
		print(i, v)
	end
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests