From 264b8d9f59be03dd68ce2c491bbf8a4d425441ac Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 30 Oct 2023 10:24:49 -0600 Subject: move gemini titan request handling from server to request parser --- gemini/serve.go | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'gemini/serve.go') diff --git a/gemini/serve.go b/gemini/serve.go index 0303c13..c76353c 100644 --- a/gemini/serve.go +++ b/gemini/serve.go @@ -4,15 +4,12 @@ import ( "bufio" "context" "crypto/tls" - "errors" "fmt" "io" "net" - "strconv" - "strings" - "tildegit.org/tjp/sliderule/internal/types" "tildegit.org/tjp/sliderule/internal" + "tildegit.org/tjp/sliderule/internal/types" "tildegit.org/tjp/sliderule/logging" ) @@ -66,13 +63,6 @@ func (s *server) handleConn(conn net.Conn) { request.TLSState = &state } - if request.Scheme == "titan" { - len, err := sizeParam(request.Path) - if err == nil { - request.Meta = io.LimitReader(buf, int64(len)) - } - } - defer func() { if r := recover(); r != nil { err := fmt.Errorf("%s", r) @@ -90,22 +80,6 @@ func (s *server) handleConn(conn net.Conn) { _, _ = io.Copy(conn, NewResponseReader(response)) } -func sizeParam(path string) (int, error) { - _, rest, found := strings.Cut(path, ";") - if !found { - return 0, errors.New("no params in path") - } - - for _, piece := range strings.Split(rest, ";") { - key, val, _ := strings.Cut(piece, "=") - if key == "size" { - return strconv.Atoi(val) - } - } - - return 0, errors.New("no size param found") -} - // GeminiOnly filters requests down to just those on the gemini:// protocol. // // Optionally, it will also allow through titan:// requests. -- cgit v1.2.3