~emersion/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH kimchi] Support Hijack, Flush when using access logs

Details
Message ID
<20230316101629.339975-1-delthas@dille.cc>
DKIM signature
missing
Download raw message
Patch: +20 -0
This fixes the following error when using WebSockets with access logs
enabled:
    http: proxy error: can't switch protocols using non-Hijacker ResponseWriter type *main.interceptRW

We also add a Hijack method for upcoming (Go 1.20) ResponseController
support.
---
 interceptor.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/interceptor.go b/interceptor.go
index 6e2fdbb..17aa1ad 100644
--- a/interceptor.go
+++ b/interceptor.go
@@ -1,6 +1,9 @@
package main

import (
	"bufio"
	"fmt"
	"net"
	"net/http"
)

@@ -10,6 +13,23 @@ type interceptRW struct {
	size   int
}

func (w *interceptRW) Unwrap() http.ResponseWriter {
	return w.ResponseWriter
}

func (w *interceptRW) Flush() {
	if f, ok := w.ResponseWriter.(http.Flusher); ok {
		f.Flush()
	}
}

func (w *interceptRW) Hijack() (net.Conn, *bufio.ReadWriter, error) {
	if h, ok := w.ResponseWriter.(http.Hijacker); ok {
		return h.Hijack()
	}
	return nil, nil, fmt.Errorf("connection does not support hijacking")
}

func (w *interceptRW) WriteHeader(status int) {
	w.status = status
	w.ResponseWriter.WriteHeader(status)

base-commit: b5c6ce57dba6a7a4b37a7baba7bb1b21c4debe69
-- 
2.39.1
Details
Message ID
<qYbGntFmXOwvCWWTBjwAnKv0eh6OUliQ58vJBAUPv5qd4o_Cu9hZbm6fMXQriisK0wW9yJFbQgmCHlGiahJQXYuyQbuT1Ai8r9zOHEnFT0s=@emersion.fr>
In-Reply-To
<20230316101629.339975-1-delthas@dille.cc> (view parent)
DKIM signature
missing
Download raw message
Pushed with two minor edits:

- Fix typo in commit message: s/Hijack/Unwrap/
- Add _ vars to ensure the interfaces are properly implemented

Thanks!
Reply to thread Export thread (mbox)