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
25244364
Commit
25244364
authored
Nov 29, 2017
by
heddn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2921708
by edysmp, drclaw, CrashTest_, heddn: Allow creation of custom headers without auth
parent
65848b6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
src/Plugin/migrate_plus/data_fetcher/Http.php
src/Plugin/migrate_plus/data_fetcher/Http.php
+15
-0
tests/src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php
.../src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php
+43
-0
No files found.
src/Plugin/migrate_plus/data_fetcher/Http.php
View file @
25244364
...
...
@@ -10,6 +10,19 @@ use GuzzleHttp\Exception\RequestException;
/**
* Retrieve data over an HTTP connection for migration.
*
* * Example:
*
* @code
* source:
* plugin: url
* data_fetcher_plugin: http
* headers:
* Accept: application/json
* User-Agent: Internet Explorer 6
* Authorization-Key: secret
* Arbitrary-Header: foobarbaz
* @endcode
*
* @DataFetcher(
* id = "http",
* title = @Translation("HTTP")
...
...
@@ -44,6 +57,8 @@ class Http extends DataFetcherPluginBase implements ContainerFactoryPluginInterf
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
httpClient
=
\
Drupal
::
httpClient
();
$this
->
setRequestHeaders
(
$configuration
[
'headers'
]);
}
/**
...
...
tests/src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php
0 → 100644
View file @
25244364
<?php
namespace
Drupal\Tests\migrate_plus\Kernel\Plugin\migrate_plus\data_fetcher
;
use
Drupal\Core\DependencyInjection\ContainerBuilder
;
use
Drupal\KernelTests\KernelTestBase
;
use
Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher
\
Http
;
use
Drupal\Tests\Core\Test\KernelTestBaseTest
;
use
Drupal\Tests\UnitTestCase
;
/**
* Class HttpTest
*
* @group migrate_plus
* @package Drupal\Tests\migrate_plus\Unit\migrate_plus\data_fetcher
*/
class
HttpTest
extends
KernelTestBase
{
/**
* Test http headers option.
*/
function
testHttpHeaders
()
{
$expected
=
[
'Accept'
=>
'application/json'
,
'User-Agent'
=>
'Internet Explorer 6'
,
'Authorization-Key'
=>
'secret'
,
'Arbitrary-Header'
=>
'foobarbaz'
];
$configuration
=
[
'headers'
=>
[
'Accept'
=>
'application/json'
,
'User-Agent'
=>
'Internet Explorer 6'
,
'Authorization-Key'
=>
'secret'
,
'Arbitrary-Header'
=>
'foobarbaz'
]
];
$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