-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement more fine-grained setting of "Connection: close" header
- Loading branch information
keks
committed
Oct 1, 2018
1 parent
91b850b
commit cb38271
Showing
3 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package http | ||
|
||
import "io" | ||
|
||
// bodyWrapper wraps an io.Reader and calls onError whenever the Read function returns an error. | ||
// This was designed for wrapping the request body, so we can know whether it was closed. | ||
type bodyWrapper struct { | ||
io.ReadCloser | ||
onError func(err error) | ||
} | ||
|
||
func (bw bodyWrapper) Read(data []byte) (int, error) { | ||
n, err := bw.ReadCloser.Read(data) | ||
if err != nil { | ||
bw.onError(err) | ||
} | ||
|
||
return n, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters