Skip to content

Commit a4fa04d

Browse files
[5.3] Enhance header handling in transport classes to support array values - (joomla#46078)
Co-authored-by: Martina Scholz <[email protected]>
1 parent b4624e5 commit a4fa04d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

libraries/src/Http/Transport/CurlTransport.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ public function request($method, UriInterface $uri, $data = null, array $headers
9999

100100
if (isset($headers)) {
101101
foreach ($headers as $key => $value) {
102-
$headerArray[] = $key . ': ' . $value;
102+
if (\is_array($value)) {
103+
foreach ($value as $header) {
104+
$headerArray[] = "$key: $header";
105+
}
106+
} else {
107+
$headerArray[] = "$key: $value";
108+
}
103109
}
104110

105111
// Add the headers string into the stream context options array.

libraries/src/Http/Transport/SocketTransport.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ public function request($method, UriInterface $uri, $data = null, array $headers
9797
// If there are custom headers to send add them to the request payload.
9898
if (\is_array($headers)) {
9999
foreach ($headers as $k => $v) {
100-
$request[] = $k . ': ' . $v;
100+
if (\is_array($v)) {
101+
foreach ($v as $value) {
102+
$request[] = "$k: $value";
103+
}
104+
} else {
105+
$request[] = "$k: $v";
106+
}
101107
}
102108
}
103109

libraries/src/Http/Transport/StreamTransport.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ public function request($method, UriInterface $uri, $data = null, array $headers
110110

111111
if (isset($headers)) {
112112
foreach ($headers as $key => $value) {
113-
$headerEntries[] = $key . ': ' . $value;
113+
if (\is_array($value)) {
114+
foreach ($value as $header) {
115+
$headerEntries[] = "$key: $header";
116+
}
117+
} else {
118+
$headerEntries[] = "$key: $value";
119+
}
114120
}
115121

116122
// Add the headers string into the stream context options array.

0 commit comments

Comments
 (0)