From 9118217048d8525b81be5ad7de400e56832dc02e Mon Sep 17 00:00:00 2001 From: sudocarlos <122110235+sudocarlos@users.noreply.github.com> Date: Fri, 9 May 2025 15:20:19 -0300 Subject: [PATCH] khatru/blossom: implement BUD-05 without optimizations --- khatru/blossom/handlers.go | 9 +++++++++ khatru/blossom/server.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/khatru/blossom/handlers.go b/khatru/blossom/handlers.go index 8f3a32f..dcf6d12 100644 --- a/khatru/blossom/handlers.go +++ b/khatru/blossom/handlers.go @@ -233,6 +233,10 @@ func (bs BlossomServer) handleHasBlob(w http.ResponseWriter, r *http.Request) { blossomError(w, "file not found", 404) return } + + w.Header().Set("Content-Length", strconv.Itoa(bd.Size)) + w.Header().Set("Accept-Ranges", "bytes") + w.Header().Set("Content-Type", bd.Type) } func (bs BlossomServer) handleList(w http.ResponseWriter, r *http.Request) { @@ -449,5 +453,10 @@ func (bs BlossomServer) handleMirror(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(bd) } +func (bs BlossomServer) handleMedia(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/upload", 307) + return +} + func (bs BlossomServer) handleNegentropy(w http.ResponseWriter, r *http.Request) { } diff --git a/khatru/blossom/server.go b/khatru/blossom/server.go index af94cd1..42b57b1 100644 --- a/khatru/blossom/server.go +++ b/khatru/blossom/server.go @@ -44,6 +44,10 @@ func New(rl *khatru.Relay, serviceURL string) *BlossomServer { } } + if r.URL.Path == "/media" { + bs.handleMedia(w, r) + return + } if r.URL.Path == "/mirror" && r.Method == "PUT" { bs.handleMirror(w, r) return