Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
M
migrate_plus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
migrate_plus
Commits
f73dec81
Commit
f73dec81
authored
Jan 03, 2018
by
tmountjr
Committed by
heddn
Jan 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2931756
by tmountjr, edysmp, heddn: NULL headers causing error
parent
3c2c48ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
18 deletions
+39
-18
src/Plugin/migrate_plus/data_fetcher/Http.php
src/Plugin/migrate_plus/data_fetcher/Http.php
+2
-0
tests/src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php
.../src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php
+37
-18
No files found.
src/Plugin/migrate_plus/data_fetcher/Http.php
View file @
f73dec81
...
...
@@ -58,6 +58,8 @@ class Http extends DataFetcherPluginBase implements ContainerFactoryPluginInterf
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
httpClient
=
\
Drupal
::
httpClient
();
// Ensure there is a 'headers' key in the configuration.
$configuration
+=
[
'headers'
=>
[]];
$this
->
setRequestHeaders
(
$configuration
[
'headers'
]);
}
...
...
tests/src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php
View file @
f73dec81
...
...
@@ -18,26 +18,45 @@ class HttpTest extends KernelTestBase {
/**
* Test http headers option.
*
* @dataProvider headerDataProvider
*/
function
testHttpHeaders
()
{
$expected
=
[
'Accept'
=>
'application/json'
,
'User-Agent'
=>
'Internet Explorer 6'
,
'Authorization-Key'
=>
'secret'
,
'Arbitrary-Header'
=>
'foobarbaz'
];
public
function
testHttpHeaders
(
array
$definition
,
array
$expected
,
array
$preSeed
=
[])
{
$http
=
new
Http
(
$definition
,
'http'
,
[]);
$this
->
assertEquals
(
$expected
,
$http
->
getRequestHeaders
());
}
$configuration
=
[
'headers'
=>
[
'Accept'
=>
'application/json'
,
'User-Agent'
=>
'Internet Explorer 6'
,
'Authorization-Key'
=>
'secret'
,
'Arbitrary-Header'
=>
'foobarbaz'
]
/**
* Provides multiple test cases for the testHttpHeaders method.
*
* @return array
* The test cases
*/
public
function
headerDataProvider
()
{
return
[
'dummy headers specified'
=>
[
'definition'
=>
[
'headers'
=>
[
'Accept'
=>
'application/json'
,
'User-Agent'
=>
'Internet Explorer 6'
,
'Authorization-Key'
=>
'secret'
,
'Arbitrary-Header'
=>
'foobarbaz'
,
],
],
'expected'
=>
[
'Accept'
=>
'application/json'
,
'User-Agent'
=>
'Internet Explorer 6'
,
'Authorization-Key'
=>
'secret'
,
'Arbitrary-Header'
=>
'foobarbaz'
,
],
],
'no headers specified'
=>
[
'definition'
=>
[
'no_headers_here'
=>
'foo'
,
],
'expected'
=>
[],
],
];
$http
=
new
Http
(
$configuration
,
'http'
,
[]);
$this
->
assertEquals
(
$expected
,
$http
->
getRequestHeaders
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment