0

How can I pass User-Agent header with a especial curl parameter -A, not -H?

official curl docs

This code adds User-Agent with -H parameter, not -A:

Http::withHeaders(['User-Agent' => 'Mozilla/5.0 (Android 13; Mobile; rv:109.0) Gecko/111.0 Firefox/111.0'])

This code has no effect:

Http::beforeSending(function(Illuminate\Http\Client\Request $request) {
    $request->toPsrRequest()
        ->withHeader('User-Agent', 'Mozilla/5.0 (Android 13; Mobile; rv:109.0) Gecko/111.0 Firefox/111.0');
});
matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
osipovmn
  • 1
  • 1

1 Answers1

1

What about

Http::withOptions([
    'CURLOPT_USERAGENT' => 'Mozilla/5.0 (Android 13; Mobile; rv:109.0) Gecko/111.0 Firefox/111.0',
]);
ahmet2106
  • 4,957
  • 4
  • 27
  • 38