Skip to content

feat: Support FlushError method - #34

Closed
tie wants to merge 1 commit into
felixge:masterfrom
tie:master
Closed

feat: Support FlushError method#34
tie wants to merge 1 commit into
felixge:masterfrom
tie:master

Conversation

@tie

@tietie commented Jun 6, 2026

Copy link
Copy Markdown

Introduced in golang/go@fd0c0db4a41 (go1.20) along with net/http.ResponseController.

Example:

package main
import (
"fmt""net/http""github.com/felixge/httpsnoop"
)
typeresponseWriterstruct {
http.ResponseWriter
}
func (w*responseWriter) Flush() {
fmt.Println("Flush called (but expected FlushError)")
}
func (w*responseWriter) FlushError() error {
fmt.Println("FlushError called (as expected)")
returnfmt.Errorf("flush error (as expected)")
}
funcmain() {
rw:=httpsnoop.Wrap(&responseWriter{}, httpsnoop.Hooks{})
rc:=http.NewResponseController(rw)
fmt.Println("Flush returned:", rc.Flush())
}

Expected output:

FlushError called (as expected)
Flush returned: flush error (as expected)

Actual output before this change:

Flush called (but expected FlushError)
Flush returned: <nil>

Introduced in golang/go@fd0c0db4a41 (go1.20)
along with net/http.ResponseController.
Example:
```go
package main
import (
"fmt"
"net/http"
"github.com/felixge/httpsnoop"
)
type responseWriter struct {
http.ResponseWriter
}
func (w *responseWriter) Flush() {
fmt.Println("Flush called (but expected FlushError)")
}
func (w *responseWriter) FlushError() error {
fmt.Println("FlushError called (as expected)")
return fmt.Errorf("flush error (as expected)")
}
func main() {
rw := httpsnoop.Wrap(&responseWriter{}, httpsnoop.Hooks{})
rc := http.NewResponseController(rw)
fmt.Println("Flush returned:", rc.Flush())
}
```
Expected output:
```
FlushError called (as expected)
Flush returned: flush error (as expected)
```
Actual output before this change:
```
Flush called (but expected FlushError)
Flush returned: <nil>
```
@tie

tie commented Jul 25, 2026

Copy link
Copy Markdown
Author

Was merged as part of #33.

@tietie closed this Jul 25, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@tie