diff --git a/collect.routing.yml b/collect.routing.yml index 7a04e67..01c778b 100644 --- a/collect.routing.yml +++ b/collect.routing.yml @@ -96,7 +96,7 @@ collect.create_entity: _controller: 'Drupal\collect\Controller\CreateEntityController::createEntity' requirements: _custom_access: 'Drupal\collect\Controller\CreateEntityController::checkAccess' - _csrf_token: 'true' + _csrf_token: 'TRUE' collect.settings: path: '/admin/config/services/collect' @@ -112,4 +112,3 @@ collect.generate_page: _controller: 'Drupal\collect\Controller\GenerateWebPageController::generatePage' requirements: _custom_access: 'Drupal\collect\Controller\GenerateWebPageController::checkAccess' - _csrf_token: 'true' diff --git a/src/Form/FetchUrlForm.php b/src/Form/FetchUrlForm.php index ab42809..4f65bc5 100644 --- a/src/Form/FetchUrlForm.php +++ b/src/Form/FetchUrlForm.php @@ -54,6 +54,8 @@ class FetchUrlForm extends FormBase { * * @param \Drupal\Core\Http\Client $http_client * The http client. + * @param \Drupal\collect\Schema\SchemaManagerInterface $schema_manager + * The injected schema plugin manager. */ public function __construct(Client $http_client, SchemaManagerInterface $schema_manager) { $this->httpClient = $http_client; @@ -140,7 +142,7 @@ class FetchUrlForm extends FormBase { if ($accept_header == 'custom') { $accept_header = $form_state->getValue('custom'); } - $request = $this->httpClient->createRequest('GET', $url, ['headers' => ['Accept' => $accept_header]]); + $request = $this->httpClient->createRequest('GET', $url, ['headers' => ['Accept' => $accept_header, 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36']]); $request_headers = $request->getHeaders(); try { // Get response headers.