Page 1 of 1

HTTPS

Posted: Wed Apr 06, 2022 7:29 pm
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.

Re: HTTPS

Posted: Thu Apr 07, 2022 12:09 pm
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

Re: HTTPS

Posted: Thu Apr 07, 2022 11:13 pm
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

Re: HTTPS

Posted: Fri Apr 08, 2022 8:16 am
by Enno
These are both great answers, thank you much!

Re: HTTPS

Posted: Sun Apr 10, 2022 4:19 pm
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?

Re: HTTPS

Posted: Sun Apr 10, 2022 4:36 pm
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

Re: HTTPS

Posted: Tue Apr 12, 2022 5:31 am
by ivan
Looking forward to HTTPS and version 12.
Great job to everybody involved in the love2d development community!

Re: HTTPS

Posted: Mon May 30, 2022 6:37 am
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?

Re: HTTPS

Posted: Mon May 30, 2022 9:08 am
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.

Re: HTTPS

Posted: Mon May 30, 2022 9:21 am
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