Skip to content

Commit 60c6de1

Browse files
committed
ACP2E-3096: Incorrect curl headers making newrelic:create:deploy-marker not working
1 parent db791f2 commit 60c6de1

File tree

1 file changed

+16
-4
lines changed
  • lib/internal/Magento/Framework/HTTP/Adapter

1 file changed

+16
-4
lines changed

lib/internal/Magento/Framework/HTTP/Adapter/Curl.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ public function write($method, $url, $http_ver = '1.1', $headers = [], $body = '
190190
}
191191

192192
if (is_array($headers)) {
193-
$curlHeaders = [];
194-
foreach ($headers as $key => $value) {
195-
$curlHeaders[] = $key . ': ' . $value;
196-
}
193+
$curlHeaders = $this->normalizeHeaders($headers);
197194
curl_setopt($this->_getResource(), CURLOPT_HTTPHEADER, $curlHeaders);
198195
}
199196

@@ -348,4 +345,19 @@ private function extractCodeFromResponse(string $responseString)
348345

349346
return false;
350347
}
348+
349+
/**
350+
* Normalizes headers to cURL format
351+
*
352+
* @param array $headers Headers to normalize. Expected format: ['name' => 'value'] or ['name: value']
353+
* @return array Normalized headers. Expected Format: ['name: value']
354+
*/
355+
private function normalizeHeaders(array $headers): array
356+
{
357+
$curlHeaders = [];
358+
foreach ($headers as $key => $value) {
359+
$curlHeaders[] = !is_int($key) ? ($key . ': ' . $value) : $value;
360+
}
361+
return $curlHeaders;
362+
}
351363
}

0 commit comments

Comments
 (0)