Skip to content

Commit

Permalink
Make definition of HTTP headers always as arrays and not strings
Browse files Browse the repository at this point in the history
To ease further HTTP headers manipulation with future HTTPS proxy (see #249) and `GOOGLE_ABUSE_EXEMPTION` cookie.

Verifying current `getContextFromOpts` correctness:

```php
<?php

$headers = 'test';

foreach ($headers as $headerIndex => $header) {
    echo "header: $header\n";
}
```
```
PHP Warning:  foreach() argument must be of type array|object, string given in /home/benjamin/test.php on line 5
```
  • Loading branch information
Benjamin-Loison committed Mar 10, 2024
1 parent 42b53ff commit 48f8e2d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion commentThreads.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function getAPI($videoId, $commentId, $order, $continuationToken, $simulatedCont
$opts = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'header' => ['Content-Type: application/json'],
'content' => json_encode($rawData),
]
];
Expand Down
4 changes: 2 additions & 2 deletions liveChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function getItem($id)

$opts = [
'http' => [
'header' => 'Content-Type: application/json',
'header' => ['Content-Type: application/json'],
'method' => 'POST',
'content' => json_encode($rawData),
]
Expand Down Expand Up @@ -106,7 +106,7 @@ function getItem($id)
$participants = [];
$opts = [
'http' => [
'header' => 'User-Agent: ' . USER_AGENT,
'header' => ['User-Agent: ' . USER_AGENT],
]
];

Expand Down
2 changes: 1 addition & 1 deletion playlistItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function getAPI($playlistId, $continuationToken)
'continuation' => $continuationToken
];
$http['method'] = 'POST';
$http['header'] = 'Content-Type: application/json';
$http['header'] = ['Content-Type: application/json'];
$http['content'] = json_encode($rawData);
} else {
$url = "https://www.youtube.com/playlist?list=$playlistId";
Expand Down
4 changes: 2 additions & 2 deletions search.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function getAPI($id, $order, $continuationToken)
$opts = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'header' => ['Content-Type: application/json'],
'content' => json_encode($rawData),
]
];
Expand Down Expand Up @@ -162,7 +162,7 @@ function getAPI($id, $order, $continuationToken)
$opts = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'header' => ['Content-Type: application/json'],
'content' => json_encode($rawData),
]
];
Expand Down

0 comments on commit 48f8e2d

Please sign in to comment.