From 634fc47f0fbd3f253a4d89fae113f884d123da5f Mon Sep 17 00:00:00 2001 From: Denis Sedchenko Date: Thu, 11 May 2023 10:30:48 +0200 Subject: [PATCH] Serve raw content length for static assets (#217) * feat: serve raw content length * fix: remove unused import --- internal/langserver/spa.go | 5 ++++- web/src/services/gorepl/service.ts | 3 ++- web/src/store/dispatchers/settings.ts | 2 +- web/src/store/reducers.ts | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/langserver/spa.go b/internal/langserver/spa.go index a264713d..3193b3ab 100644 --- a/internal/langserver/spa.go +++ b/internal/langserver/spa.go @@ -5,6 +5,7 @@ import ( "os" "path" "path/filepath" + "strconv" "strings" ) @@ -54,13 +55,15 @@ func (fs *SpaFileServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { name := path.Join(dir, filepath.FromSlash(upath)) //check if file exists - if _, err := os.Stat(name); err != nil { + s, err := os.Stat(name) + if err != nil { if os.IsNotExist(err) { fs.NotFoundHandler.ServeHTTP(rw, r) return } } + rw.Header().Set(rawContentLengthHeader, strconv.FormatInt(s.Size(), 10)) http.ServeFile(rw, r, name) } diff --git a/web/src/services/gorepl/service.ts b/web/src/services/gorepl/service.ts index e784d86e..15095c27 100644 --- a/web/src/services/gorepl/service.ts +++ b/web/src/services/gorepl/service.ts @@ -3,7 +3,8 @@ import {EvalEventKind} from "../api"; import {ConsoleStreamType} from "~/lib/gowasm/bindings/stdio"; import { newErrorAction, - newLoadingAction, newProgramFinishAction, newProgramStartAction, + newProgramFinishAction, + newProgramStartAction, newProgramWriteAction, } from "~/store/actions"; import {DispatchFn, StateProvider} from "~/store/helpers"; diff --git a/web/src/store/dispatchers/settings.ts b/web/src/store/dispatchers/settings.ts index bff7d171..29fc4cd0 100644 --- a/web/src/store/dispatchers/settings.ts +++ b/web/src/store/dispatchers/settings.ts @@ -1,7 +1,7 @@ import {isDarkModeEnabled} from "~/utils/theme"; import config, {RunTargetConfig} from '~/services/config'; -import { Dispatcher, StateDispatch } from "./utils"; +import { Dispatcher } from "./utils"; import {PanelState, SettingsState} from "../state"; import { StateProvider, DispatchFn } from "../helpers"; import { diff --git a/web/src/store/reducers.ts b/web/src/store/reducers.ts index 0d9c798b..ac422222 100644 --- a/web/src/store/reducers.ts +++ b/web/src/store/reducers.ts @@ -2,7 +2,7 @@ import { connectRouter } from 'connected-react-router'; import { combineReducers } from 'redux'; import {editor} from 'monaco-editor'; -import { RunResponse, EvalEvent } from '~/services/api'; +import { EvalEvent } from '~/services/api'; import config, { MonacoSettings, RunTargetConfig