From 2dc6f581cc7ea5551fa759686ce07189d710e379 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 22 Sep 2022 18:19:53 +0900 Subject: [PATCH] changing the acceptable url format for the http modem to drop the double slashes after the 'http' or somethingas the they get replaced into single one on command.js but not on the user program, producing discrepancy --- assets/disk0/nettest.js | 2 +- tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/disk0/nettest.js b/assets/disk0/nettest.js index 0195f77..8f8ea83 100644 --- a/assets/disk0/nettest.js +++ b/assets/disk0/nettest.js @@ -1,4 +1,4 @@ -let url="http://localhost/testnet/test.txt" +let url="http:localhost/testnet/test.txt" let file = files.open("B:\\"+url) diff --git a/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt b/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt index 7afc396..8906bef 100644 --- a/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt +++ b/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt @@ -11,6 +11,10 @@ import java.net.URL /** + * To get a text from the web address, send message: `GET https:en.wikipedia.org/wiki/Http` + * + * Note that there is no double-slash after the protocol (or scheme) + * * Created by minjaesong on 2022-09-22. */ class HttpModem(private val vm: VM) : BlockTransferInterface(false, true) { @@ -115,6 +119,8 @@ class HttpModem(private val vm: VM) : BlockTransferInterface(false, true) { printdbg("msg: $inputString, lastIndex: ${inputString.lastIndex}") cnxUrl = inputString.substring(4).filter { it in '!'..'~' } + val protocolSep = cnxUrl!!.indexOf(':') + cnxUrl = cnxUrl!!.substring(0, protocolSep) + "://" + cnxUrl!!.substring(protocolSep + 1) printdbg("URL: $cnxUrl")