Using Web Server DAT with SSL

I’m having trouble using SSL with the Web Server DAT. It works fine with http, but when I try to switch over to https, I get weird problems. For instance, if I connect with Firefox, I can load an HTML page just fine but if I try to refresh that same page, I get a PR_END_OF_FILE_ERROR.

Since it works fine on http, I’m tempted to think that my code is correct, but maybe I’m overlooking something. This is on macOS with TouchDesigner v2021.12380.

Here’s the code that handles HTTP requests:

def onHTTPRequest(webServerDAT, request, response):

	utf8 = [
		"application/javascript",
		"application/json",
		"text/css",
		"text/javascript"
	]

	# Path
	path = "www" + request["uri"]
	if (request["uri"].endswith('/')): path += "index.html"

	# MIME Type
	type = mimetypes.guess_type(chemin)[0] # tuple: (type, encodage)
	if type in utf8: type += "; charset=utf-8"

	# Response
	try:
		reader = open(path, "r")
		data = reader.read()
		reader.close()
		response['statusCode'] = 200
		response['statusReason'] = 'OK'
		response['content-type'] = type
		response['data'] = data
	except FileNotFoundError:
		response['statusCode'] = 404
		response['statusReason'] = 'Not Found'

	return response

Ideas?

I just tried my project on Windows and it works (v2021.10330). So, it seems to be a macOS-only problem.

Has anybody successfully used the WebServer DAT with SSL on macOS ?

We’re able to reproduce the issue and are working on a fix. The regression must have happened within the last year as I believe it was working in 2020.24520.

This issue will be fixed in the next official build we release, 2021.12700+

1 Like