File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -46,16 +46,21 @@ public function __construct(
46
46
47
47
public function add (
48
48
UriInterface $ uri ,
49
- array $ init ,
49
+ array $ curlOptArray ,
50
50
Deferred $ deferred
51
51
):void {
52
52
/** @var CurlInterface $curl */
53
53
$ curl = new $ this ->curlClass ($ uri );
54
54
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 );
57
61
}
58
62
63
+ // curlopt3: Finally, hard-code these curlopt settings:
59
64
$ curl ->setOpt (CURLOPT_RETURNTRANSFER , false );
60
65
$ curl ->setOpt (CURLOPT_HEADER , false );
61
66
$ curl ->setOpt (CURLOPT_HEADERFUNCTION , [$ this , "writeHeader " ]);
You can’t perform that action at this time.
0 commit comments