Skip to content

Commit

Permalink
chore: refactor rest/timeouthandler (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Jan 5, 2022
1 parent a91c390 commit ba6a7c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rest/handler/timeouthandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ type timeoutWriter struct {

var _ http.Pusher = (*timeoutWriter)(nil)

// Header returns the underline temporary http.Header.
func (tw *timeoutWriter) Header() http.Header { return tw.h }

// Push implements the Pusher interface.
func (tw *timeoutWriter) Push(target string, opts *http.PushOptions) error {
if pusher, ok := tw.w.(http.Pusher); ok {
Expand All @@ -126,8 +129,8 @@ func (tw *timeoutWriter) Push(target string, opts *http.PushOptions) error {
return http.ErrNotSupported
}

func (tw *timeoutWriter) Header() http.Header { return tw.h }

// Write writes the data to the connection as part of an HTTP reply.
// Timeout and multiple header written are guarded.
func (tw *timeoutWriter) Write(p []byte) (int, error) {
tw.mu.Lock()
defer tw.mu.Unlock()
Expand Down

0 comments on commit ba6a7c9

Please sign in to comment.