Skip to content

Commit 24e8e01

Browse files
committed
updated tests
1 parent dc6caf0 commit 24e8e01

File tree

151 files changed

+12511
-72636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+12511
-72636
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [4.1.2] - Unreleased
9+
### Added
10+
- Added the `ignored_errors` settings to ignore some curls errors instead throw an exception [#355]
11+
12+
### Fixed
13+
- Ignored linkedData errors [#356]
14+
815
## [4.1.1] - 2020-04-24
916
### Added
1017
- Updated oembed endpoints from `oembed.com`
@@ -44,6 +51,9 @@ Full library refactoring.
4451

4552
[#345]: https://github.com/oscarotero/Embed/issues/345
4653
[#346]: https://github.com/oscarotero/Embed/issues/346
54+
[#355]: https://github.com/oscarotero/Embed/issues/355
55+
[#356]: https://github.com/oscarotero/Embed/issues/356
4756

57+
[4.1.2]: https://github.com/oscarotero/Embed/compare/v4.1.1...HEAD
4858
[4.1.1]: https://github.com/oscarotero/Embed/compare/v4.1.0...v4.1.1
4959
[4.1.0]: https://github.com/oscarotero/Embed/compare/v4.0.0...v4.1.0

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ use Embed\Http\Crawler;
316316
use Embed\Http\CurlClient;
317317

318318
$client = new CurlClient();
319-
$client->setSettings(['cookies_path' => $cookies_path]);
319+
$client->setSettings([
320+
'cookies_path' => $cookies_path,
321+
'ignored_errors' => [18]
322+
]);
320323

321324
$embed = new Embed(new Crawler($client));
322325
```

src/Http/CurlDispatcher.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ final class CurlDispatcher
1818
private array $headers = [];
1919
private $body;
2020
private ?int $error = null;
21+
private array $settings;
2122

2223
/**
2324
* @return ResponseInterface[]
@@ -78,6 +79,7 @@ private function __construct(array $settings, RequestInterface $request)
7879
{
7980
$this->request = $request;
8081
$this->curl = curl_init((string) $request->getUri());
82+
$this->settings = $settings;
8183

8284
$cookies = $settings['cookies_path'] ?? str_replace('//', '/', sys_get_temp_dir().'/embed-cookies.txt');
8385

@@ -140,6 +142,12 @@ private function exec(ResponseFactoryInterface $responseFactory): ResponseInterf
140142

141143
private function error(string $message, int $code)
142144
{
145+
$ignored = $this->settings['ignored_errors'] ?? null;
146+
147+
if ($ignored === true || (is_array($ignored) && in_array($code, $ignored))) {
148+
return;
149+
}
150+
143151
throw new NetworkException($message, $code, $this->request);
144152
}
145153

tests/cache/500px.com.photo-138251239-taganay-park-by-daniel-kordan.php

Lines changed: 19 additions & 16 deletions
Large diffs are not rendered by default.

tests/cache/animoto.com.oembeds-create.json.416acbaec2e9fc6d8914b6044b652aad.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
'default-src \'self\' https:; base-uri \'self\'; block-all-mixed-content; child-src \'self\' https: blob:; connect-src \'self\' wss: https: blob:; font-src \'self\' data: https:; form-action \'self\' forms.hsforms.com www.facebook.com; frame-ancestors \'self\' app.optimizely.com *.eventbrite.com video214.com animoto.com; img-src \'self\' data: https: blob: android-webview-video-poster:; manifest-src \'self\'; media-src \'self\' https: data: blob:; object-src \'self\' www.paypalobjects.com d150hyw1dtprld.cloudfront.net; prefetch-src \'self\' https:; script-src \'self\' https: data: \'unsafe-inline\' \'unsafe-eval\'; style-src \'self\' https: \'unsafe-inline\'; upgrade-insecure-requests; worker-src \'self\' blob:; report-uri https://sentry.io/api/1401029/security/?sentry_key=b94ac67e5c014425a0fe8cb868528601'
2323
],
2424
'date' => [
25-
'Sat, 22 Feb 2020 23:46:43 GMT'
25+
'Wed, 20 May 2020 17:53:09 GMT'
2626
],
2727
'etag' => [
28-
'W/"79b8b73f64cfcfd22eda671b8c3f384d"'
28+
'W/"128c48bd9bf19eef7a2f498d8b3fd06f"'
2929
],
3030
'referrer-policy' => [
3131
'origin-when-cross-origin'
@@ -43,7 +43,7 @@
4343
'web2-http.production.svc.cluster.local:8000/*'
4444
],
4545
'x-envoy-upstream-service-time' => [
46-
'242'
46+
'209'
4747
],
4848
'x-frame-options' => [
4949
'ALLOW-FROM https://app.optimizely.com'
@@ -52,10 +52,10 @@
5252
'none'
5353
],
5454
'x-request-id' => [
55-
'4c802b3885e00d2fa2e267ae3cca1bbb'
55+
'f1a95949ccad0e42051f89bd3b309786'
5656
],
5757
'x-runtime' => [
58-
'0.240879'
58+
'0.207826'
5959
],
6060
'x-served-by' => [
6161
'nginx-ingress-controller-68b4bf9c-zn7p5'
@@ -67,19 +67,22 @@
6767
'Miss from cloudfront'
6868
],
6969
'via' => [
70-
'1.1 4a41a68aa92d1d4a548f11fe8c9bc79e.cloudfront.net (CloudFront)'
70+
'1.1 950bb8c57b98d41ce5118fe9b4561e37.cloudfront.net (CloudFront)'
7171
],
7272
'x-amz-cf-pop' => [
7373
'MAD51-C1'
7474
],
7575
'x-amz-cf-id' => [
76-
'Jkm3d-rGX_dDqCI1kLNG3l4v4jnbJ111Tdck_sMW6nGtahW1egQM3g=='
76+
'oWpBURK5bOSttReEaYL0aM8cnKzXafKw1O80S7RgyH_51EaiV0sHSA=='
7777
],
7878
'Content-Location' => [
7979
'https://animoto.com/oembeds/create.json?automated=true&options=start_hq&url=https%3A%2F%2Fanimoto.com%2Fplay%2FGjsJ1gu0WDRfr4pGw12xZQ'
80+
],
81+
'X-Request-Time' => [
82+
'0.631 ms'
8083
]
8184
],
8285
'statusCode' => 200,
8386
'reasonPhrase' => 'OK',
84-
'body' => '{"version":1.0,"provider_name":"Animoto","provider_url":"https://animoto.com/","type":"video","author_name":null,"title":"taco bell","description":"","thumbnail_url":"https://d2m23yiuv18ohn.cloudfront.net/Video/GjsJ1gu0WDRfr4pGw12xZQ/cover_648x360.jpg","thumbnail_height":360,"thumbnail_width":648,"icon_url":"https://d2m23yiuv18ohn.cloudfront.net/Video/GjsJ1gu0WDRfr4pGw12xZQ/cover_224x126.jpg","icon_height":54,"icon_width":54,"width":640,"height":360,"cache_age":604800,"video_url":"https://d150hyw1dtprld.cloudfront.net/swf/w.swf?w=swf/production/vp1&e=1582415203&f=GjsJ1gu0WDRfr4pGw12xZQ&d=0&m=b&r=360p&i=m&asset_domain=s3-p.animoto.com&animoto_domain=animoto.com&options=start_hq","html":"<iframe id=\\"vp1GjsJ1\\" title=\\"Video Player\\" width=\\"640\\" height=\\"360\\" frameborder=\\"0\\" src=\\"https://s3.amazonaws.com/embed.animoto.com/play.html?w=swf/production/vp1&e=1582415203&f=GjsJ1gu0WDRfr4pGw12xZQ&d=0&m=b&r=360p&i=m&asset_domain=s3-p.animoto.com&animoto_domain=animoto.com&options=start_hq\\" allowfullscreen></iframe>"}'
87+
'body' => '{"version":1.0,"provider_name":"Animoto","provider_url":"https://animoto.com/","type":"video","author_name":null,"title":"taco bell","description":"","thumbnail_url":"https://d2m23yiuv18ohn.cloudfront.net/Video/GjsJ1gu0WDRfr4pGw12xZQ/cover_648x360.jpg","thumbnail_height":360,"thumbnail_width":648,"icon_url":"https://d2m23yiuv18ohn.cloudfront.net/Video/GjsJ1gu0WDRfr4pGw12xZQ/cover_224x126.jpg","icon_height":54,"icon_width":54,"width":640,"height":360,"cache_age":604800,"video_url":"https://d150hyw1dtprld.cloudfront.net/swf/w.swf?w=swf/production/vp1&e=1589997189&f=GjsJ1gu0WDRfr4pGw12xZQ&d=0&m=p&r=360p&i=m&asset_domain=s3-p.animoto.com&animoto_domain=animoto.com&options=start_hq","html":"<iframe id=\\"vp1GjsJ1\\" title=\\"Video Player\\" width=\\"640\\" height=\\"360\\" frameborder=\\"0\\" src=\\"https://s3.amazonaws.com/embed.animoto.com/play.html?w=swf/production/vp1&e=1589997189&f=GjsJ1gu0WDRfr4pGw12xZQ&d=0&m=p&r=360p&i=m&asset_domain=s3-p.animoto.com&animoto_domain=animoto.com&options=start_hq\\" allowfullscreen></iframe>"}'
8588
];

0 commit comments

Comments
 (0)