Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Clone request headers #798

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions pkg/abstractions/endpoint/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,7 @@ func (rb *RequestBuffer) handleHttpRequest(req *request, c container) {
}

// Copy headers to new request
for key, values := range request.Header {
for _, val := range values {
httpReq.Header.Add(key, val)
}
}
httpReq.Header = request.Header.Clone()

httpReq.Header.Add("X-TASK-ID", req.task.msg.TaskId) // Add task ID to header
go rb.heartBeat(req, c.id) // Send heartbeat via redis for duration of request
Expand All @@ -468,17 +464,10 @@ func (rb *RequestBuffer) handleHttpRequest(req *request, c container) {

defer resp.Body.Close()

responseHeaders := make(http.Header)
for key, values := range resp.Header {
for _, value := range values {
responseHeaders.Add(key, value)
}
}

// Write response headers
for key, values := range responseHeaders {
for key, values := range resp.Header.Clone() {
for _, value := range values {
req.ctx.Response().Writer.Header().Add(key, value)
req.ctx.Response().Header().Add(key, value)
}
}

Expand Down
Loading