Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add option to override default user agent for boost mode crawler #417

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Classes/Service/ClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class ClientService extends AbstractService
{
protected const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0';

public function __construct(protected EventDispatcherInterface $eventDispatcher) {}

/**
Expand Down Expand Up @@ -64,7 +66,7 @@ protected function getCallableClient(string $domain): Client
'max' => false,
],
'headers' => [
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0',
'User-Agent' => GeneralUtility::makeInstance(ConfigurationService::class)->get('overrideClientUserAgent') ?? self::DEFAULT_USER_AGENT
],
];

Expand Down
3 changes: 3 additions & 0 deletions ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ boostMode = 0
# cat=basic; type=options[Current=current,Childs=childs,Both=both]; label=Backend display options: The backend module should display cache entries of the current page, only the direct children or both?
backendDisplayMode = both

# cat=basic; type=string; label=Client user agent: Overrides the default user agent of the boost mode crawler, if set.
overrideClientUserAgent =

# cat=basic; type=boolean; label=Debug headers: Send debug headers to get a information which component deliver the file (X-SFC-State).
debugHeaders = 0

Expand Down