Skip to content

Commit

Permalink
Merge pull request #4 from beefsack/issue-3
Browse files Browse the repository at this point in the history
Ignore client connection close syscall.EPIPE errors when writing resp…
  • Loading branch information
beefsack authored Aug 29, 2020
2 parents 4c1c575 + 58c6e5f commit 8d7a2f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Ignore client connection close errors (specifically ignoring syscall.EPIPE)

## [1.4.0] - 2020-08-29
## Added
Expand Down
4 changes: 3 additions & 1 deletion lib/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os/exec"
"sync"
"syscall"
)

// Server is a simple proxy server to pipe HTTP requests to a subprocess' stdin
Expand Down Expand Up @@ -111,7 +112,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// Write stdout as the response body
_, err = w.Write(stdout)
if err != nil {
// We ignore connection close errors, which appears as `syscall.EPIPE`
if err != nil && err != syscall.EPIPE {
log.Printf("error writing response body: %v", err)
}
}
Expand Down

0 comments on commit 8d7a2f8

Please sign in to comment.