Skip to content

Commit f9387ed

Browse files
author
Greg Bowler
committed
Send default useragent string
1 parent 6ad4aa5 commit f9387ed

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/RequestResolver.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,21 @@ public function __construct(
4646

4747
public function add(
4848
UriInterface $uri,
49-
array $init,
49+
array $curlOptArray,
5050
Deferred $deferred
5151
):void {
5252
/** @var CurlInterface $curl */
5353
$curl = new $this->curlClass($uri);
5454

55-
if(!empty($init["curlopt"])) {
56-
$curl->setOptArray($init["curlopt"]);
55+
// curlopt1: Set the default curlopt values here:
56+
$curl->setOpt(CURLOPT_USERAGENT, "PHP.Gt/Fetch");
57+
58+
// curlopt2: Then override any curlopt values that are provided:
59+
if(!empty($curlOptArray)) {
60+
$curl->setOptArray($curlOptArray);
5761
}
5862

63+
// curlopt3: Finally, hard-code these curlopt settings:
5964
$curl->setOpt(CURLOPT_RETURNTRANSFER, false);
6065
$curl->setOpt(CURLOPT_HEADER, false);
6166
$curl->setOpt(CURLOPT_HEADERFUNCTION, [$this, "writeHeader"]);

0 commit comments

Comments
 (0)