Closed ryankoppenhaver closed 13 years ago
I wonder what would happen if uri
in the code as it stands right now were changed to begin with //
as opposed to http://
. Would that obviate this pull request? (the first part, at least)
Yeah, that works just fine for the socket.io over https part. (And, as I said, I don't know if there's any actual demand for the rest of it.)
I think all the desired functionality has been implemented in some form or another. (options.protocol
for extra specificity, namely serving the HTML via file:///
and having NowJS served via node, which was broken by the use of //
.)
The motivation for this patch is to auto-host now.js on an https only server, but hopefully it makes things a little more flexible too.
Currently, nowjs.initialize() takes 'host' and 'port' options, which stuffs into the client-side script, and uses them to (1) construct an absolute URI to load the socket.io client script, and (2) to initialize the io.Socket object. This has a couple of limitations: the URI for the script is hard-coded as http (not -s), there's no way to pass the "secure" flag to socket.io, and there's no way to specify a different host for the socket.io script. (For that last one, I admit I'm not sure why someone might auto-host now.js, but not socket.io, but hey.)
With 0.7, socket.io is initialized with a URI, and now.js currently just concatenates the server and port to create this URI. With this patch, the user specifies the URI ("ioUri" in the options object), allowing it to be https. This replaces the 'host' and 'port' options. The default case, auto-hosted now.js and socket.io, with no URI specified, "just works" for http (still) and https (new!).
I've also created another option ("scriptSource"), so that one can specify a base URI for socket.io, and any other client-side dependencies, separately.