Skip to content

Commit 6f9e4e6

Browse files
committed
bug fix: remove CopyHeaders (should be used to get response headers) and add authentication and content type headers to the request
1 parent ac21f1b commit 6f9e4e6

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

api/pkg/services/emulator_push_queue.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,21 @@ func (queue *emulatorPushQueue) push(task PushQueueTask, queueID string) func()
5959
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
6060
defer cancel()
6161

62-
err := requests.
62+
request := requests.
6363
URL(task.URL).
6464
Client(queue.client).
65-
CopyHeaders(queue.httpHeaders(task)).
6665
Method(task.Method).
67-
BodyBytes(task.Body).
68-
Fetch(ctx)
66+
BodyBytes(task.Body)
67+
68+
// add headers
69+
for key, value := range task.Headers {
70+
request.Header(key, value)
71+
}
72+
73+
// add content type
74+
request.Header("Content-Type", "application/json")
75+
76+
err := request.Fetch(ctx)
6977
if err != nil {
7078
queue.logger.Error(stacktrace.Propagate(err, fmt.Sprintf("cannot send http request to [%s] for queue task [%s]", task.URL, queueID)))
7179
return
@@ -74,11 +82,3 @@ func (queue *emulatorPushQueue) push(task PushQueueTask, queueID string) func()
7482
queue.logger.Info(fmt.Sprintf("queue task [%s] sent to URL [%s]", queueID, task.URL))
7583
}
7684
}
77-
78-
func (queue *emulatorPushQueue) httpHeaders(task PushQueueTask) map[string][]string {
79-
headers := map[string][]string{}
80-
for key, value := range task.Headers {
81-
headers[key] = []string{value}
82-
}
83-
return headers
84-
}

0 commit comments

Comments
 (0)