summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/markdown
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-10-15 14:07:10 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-10-15 14:07:10 -0600
commitabf5ab340ed76792214ae80c62df7abe0ad1b8a8 (patch)
treef0cedd8a36fb03a2ad324c9398180aafb8bd462a /modules/caddyhttp/markdown
parentacf7dea68fe6ace110221faa26c2503a1ea432ce (diff)
caddyhttp: Improve ResponseRecorder to buffer headers
Diffstat (limited to 'modules/caddyhttp/markdown')
-rw-r--r--modules/caddyhttp/markdown/markdown.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/caddyhttp/markdown/markdown.go b/modules/caddyhttp/markdown/markdown.go
index 122aad6..5ff18b8 100644
--- a/modules/caddyhttp/markdown/markdown.go
+++ b/modules/caddyhttp/markdown/markdown.go
@@ -48,8 +48,8 @@ func (m Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
buf.Reset()
defer bufPool.Put(buf)
- shouldBuf := func(status int) bool {
- return strings.HasPrefix(w.Header().Get("Content-Type"), "text/")
+ shouldBuf := func(status int, header http.Header) bool {
+ return strings.HasPrefix(header.Get("Content-Type"), "text/")
}
rec := caddyhttp.NewResponseRecorder(w, buf, shouldBuf)
@@ -62,6 +62,8 @@ func (m Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
return nil
}
+ caddyhttp.CopyHeader(w.Header(), rec.Header())
+
output := blackfriday.Run(buf.Bytes())
w.Header().Set("Content-Length", strconv.Itoa(len(output)))