Skip to content

Commit 6984ac8

Browse files
committed
Merge pull request #29 from jdreesen/fix-stream-context-options-headers
Transform HTTP headers from stream context options to array
1 parent 66d5524 commit 6984ac8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/AbstractSoapClientBase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ public function getStreamContextOptions()
420420
$context = $this->getStreamContext();
421421
if ($context !== null) {
422422
$options = stream_context_get_options($context);
423+
if (isset($options['http']['header']) && is_string($options['http']['header'])) {
424+
$options['http']['header'] = array_filter(array_map('trim', explode(PHP_EOL, $options['http']['header'])));
425+
}
423426
}
424427
return $options;
425428
}

tests/SoapClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ public function testSetHeadersOnExistingHttpHeadersWithGetStreamContextOptions()
363363
$this->assertSame(array(
364364
'X-HEADER' => 'X-VALUE',
365365
), $o['http']['Auth']);
366-
$this->assertTrue(strpos($o['http']['header'], 'X-Header-Name: X-Header-Value') !== false);
367-
$this->assertTrue(strpos($o['http']['header'], 'X-Header-ID: X-Header-ID-Value') !== false);
366+
$this->assertContains('X-Header-Name: X-Header-Value', $o['http']['header']);
367+
$this->assertContains('X-Header-ID: X-Header-ID-Value', $o['http']['header']);
368368
}
369369
/**
370370
*

0 commit comments

Comments
 (0)