summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Buckley-Houston <tom@tombh.co.uk>2022-07-16 17:06:46 -0400
committerThomas Buckley-Houston <tom@tombh.co.uk>2022-07-16 17:18:39 -0400
commitaaea254f0dd1a307036f7ef3e7398da91667b023 (patch)
tree62938981d11d56df06369f16a2054f821924bdb3
parent1f20113bc035c6714a5678cb2185d429aa8deae7 (diff)
fix: Don't load startup URL in HTTP Server mode
I think this is the source of a long-standing issue in the HTTP Server where it would just freeze after a certain period of time. Every successful page load, wether it was explicitly requested as a raw-text request or not, attempts to send a raw text payload on page load. So I think the automatic default home page startup loading was confusing things. Fixes #207
-rw-r--r--interfacer/src/browsh/browsh.go7
-rw-r--r--interfacer/src/browsh/comms.go4
-rw-r--r--interfacer/src/browsh/raw_text_server.go1
-rw-r--r--webext/src/background/tab_commands_mixin.js15
4 files changed, 18 insertions, 9 deletions
diff --git a/interfacer/src/browsh/browsh.go b/interfacer/src/browsh/browsh.go
index 0cb20fa..fde4ca5 100644
--- a/interfacer/src/browsh/browsh.go
+++ b/interfacer/src/browsh/browsh.go
@@ -37,9 +37,10 @@ var (
********///////////////
***********************`
// IsTesting is used in tests, so it needs to be exported
- IsTesting = false
- logfile string
- _ = pflag.Bool("version", false, "Output current Browsh version")
+ IsTesting = false
+ IsHTTPServerMode = false
+ logfile string
+ _ = pflag.Bool("version", false, "Output current Browsh version")
)
func setupLogging() {
diff --git a/interfacer/src/browsh/comms.go b/interfacer/src/browsh/comms.go
index 9bfada9..b9ca96d 100644
--- a/interfacer/src/browsh/comms.go
+++ b/interfacer/src/browsh/comms.go
@@ -158,7 +158,9 @@ func webSocketServer(w http.ResponseWriter, r *http.Request) {
// work. So we do it here instead.
validURL := viper.GetStringSlice("validURL")
if len(validURL) == 0 {
- sendMessageToWebExtension("/new_tab," + viper.GetString("startup-url"))
+ if !IsHTTPServerMode {
+ sendMessageToWebExtension("/new_tab," + viper.GetString("startup-url"))
+ }
} else {
for i := 0; i < len(validURL); i++ {
sendMessageToWebExtension("/new_tab," + validURL[i])
diff --git a/interfacer/src/browsh/raw_text_server.go b/interfacer/src/browsh/raw_text_server.go
index 8f50ff9..479f333 100644
--- a/interfacer/src/browsh/raw_text_server.go
+++ b/interfacer/src/browsh/raw_text_server.go
@@ -66,6 +66,7 @@ type rawTextResponse struct {
// it will return:
// `Something `
func HTTPServerStart() {
+ IsHTTPServerMode = true
StartFirefox()
go startWebSocketServer()
Log("Starting Browsh HTTP server")
diff --git a/webext/src/background/tab_commands_mixin.js b/webext/src/background/tab_commands_mixin.js
index d26baeb..0ffe584 100644
--- a/webext/src/background/tab_commands_mixin.js
+++ b/webext/src/background/tab_commands_mixin.js
@@ -47,11 +47,16 @@ export default MixinBase =>
}
_rawTextRequest(incoming) {
- let payload = {
- json: JSON.stringify(incoming),
- request_id: this.request_id
- };
- this.sendToTerminal(`/raw_text,${JSON.stringify(payload)}`);
+ // I think the only reason that a tab would send a raw text payload is the
+ // automatic startup URL loading, which should now be disabled for HTTP Server
+ // mode.
+ if (this.request_id) {
+ let payload = {
+ json: JSON.stringify(incoming),
+ request_id: this.request_id
+ };
+ this.sendToTerminal(`/raw_text,${JSON.stringify(payload)}`);
+ }
this._tabCount(count => {
if (count > 1) {
this.remove();