Skip to content

Commit

Permalink
update error handler to include current response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
pirtleshell committed Feb 8, 2024
1 parent 67422b4 commit 6aecf95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion service/batchmdw/batch_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (bp *BatchProcessor) applyHeaders(h http.Header) {
}

// SetErrStatus tracks an error status code if any request returns a non-200 response
func (bp *BatchProcessor) setErrStatus(status int, _ *bytes.Buffer) {
func (bp *BatchProcessor) setErrStatus(status int, _ http.Header, _ *bytes.Buffer) {
bp.mu.Lock()
defer bp.mu.Unlock()
bp.status = status
Expand Down
4 changes: 2 additions & 2 deletions service/batchmdw/fake_response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
)

type ErrorHandler = func(status int, rawRes *bytes.Buffer)
type ErrorHandler = func(status int, headers http.Header, body *bytes.Buffer)

// fakeResponseWriter is a custom implementation of http.ResponseWriter that writes all content
// to a buffer.
Expand Down Expand Up @@ -47,6 +47,6 @@ func (w *fakeResponseWriter) Header() http.Header {
// it overrides the WriteHeader method to prevent proxied requests from having finalized headers
func (w *fakeResponseWriter) WriteHeader(status int) {
if status != http.StatusOK {
w.onErrorHandler(status, w.body)
w.onErrorHandler(status, w.header, w.body)
}
}

0 comments on commit 6aecf95

Please sign in to comment.