@@ -33,6 +33,7 @@ class NextcloudApiContext implements Context {
3333 protected static array $ environments = [];
3434 protected static string $ commandOutput = '' ;
3535 protected int $ startWaitFor = 0 ;
36+ protected array $ customHeaders = [];
3637
3738 /**
3839 * @var string[]
@@ -189,7 +190,8 @@ public function sendRequest(string $verb, string $url, $body = null, array $head
189190
190191 $ options ['headers ' ] = array_merge ($ headers , [
191192 'Accept ' => 'application/json ' ,
192- ]);
193+ ], $ this ->customHeaders );
194+
193195 if ($ this ->currentUser === 'admin ' ) {
194196 $ options ['auth ' ] = ['admin ' , $ this ->adminPassword ];
195197 } elseif ($ this ->currentUser ) {
@@ -207,6 +209,15 @@ public function sendRequest(string $verb, string $url, $body = null, array $head
207209 }
208210 }
209211
212+ #[Given('/^set the custom http header "([^"]*)" with "([^"]*)" as value to next request$/ ' )]
213+ public function setTheCustomHttpHeaderAsValueToNextRequest (string $ header , string $ value ):void {
214+ if (empty ($ value )) {
215+ unset($ this ->customHeaders [$ header ]);
216+ return ;
217+ }
218+ $ this ->customHeaders [$ header ] = $ this ->parseText ($ value );
219+ }
220+
210221 protected function beforeRequest (string $ fullUrl , array $ options ): array {
211222 $ options = $ this ->parseFormParams ($ options );
212223 $ fullUrl = $ this ->parseText ($ fullUrl );
0 commit comments