Skip to content

Commit

Permalink
Network: enable parsing of 'https' URL and TLS flag even even TLS not…
Browse files Browse the repository at this point in the history
… built in (#2410)
  • Loading branch information
gfwilliams committed Oct 10, 2024
1 parent 1ee728e commit 0c89774
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
Graphic.createArrayBuffer msb now defaults to true as it's rare to ever need msb:false
Ensure Math.random() can never be `1` as per spec (was unlikely before, but possible)
Add Math.randInt: not in spec, but very useful for embedded
Fix debugging of switch statements (fix #2562)
Network: enable parsing of 'https' URL and TLS flag even even TLS not built in (#2410)

2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Expand Down
2 changes: 0 additions & 2 deletions libs/network/jswrap_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,13 @@ JsVar *jswrap_net_connect(JsVar *options, JsVar *callback, SocketType socketType
jsError("Expecting Options to be an Object but it was %t", options);
return 0;
}
#ifdef USE_TLS
if ((socketType&ST_TYPE_MASK) == ST_HTTP) {
JsVar *protocol = jsvObjectGetChildIfExists(options, "protocol");
if (protocol && jsvIsStringEqual(protocol, "https:")) {
socketType |= ST_TLS;
}
jsvUnLock(protocol);
}
#endif

// Make sure we have a function as callback, or nothing (which is OK too)
if (!jsvIsUndefined(callback) && !jsvIsFunction(callback)) {
Expand Down
2 changes: 0 additions & 2 deletions libs/network/socketserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,11 +1048,9 @@ void clientRequestConnect(JsNetwork *net, JsVar *httpClientReqVar) {
return;
}

#ifdef USE_TLS
if (socketType & ST_TLS) {
if (port==0) port = 443;
}
#endif
if ((socketType&ST_TYPE_MASK) == ST_HTTP) {
if (port==0) port = 80;
}
Expand Down

0 comments on commit 0c89774

Please sign in to comment.