From 0281abafb6927877946357fae119e7f6f0d9c1ee Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Thu, 21 Oct 2021 20:30:39 +0200 Subject: [PATCH] Drop support for XP < 9 See xp-framework/rfc#341 --- ChangeLog.md | 5 +++++ composer.json | 8 ++++---- src/main/php/webservices/rest/io/Buffered.class.php | 2 +- src/main/php/webservices/rest/io/Traced.class.php | 2 +- .../php/webservices/rest/unittest/CookiesTest.class.php | 3 ++- .../rest/unittest/format/FormUrlencodedTest.class.php | 2 +- .../webservices/rest/unittest/format/JsonTest.class.php | 4 ++-- .../webservices/rest/unittest/format/NdJsonTest.class.php | 6 +++--- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cf58014..f6af12f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,11 @@ Rest client change log ## ?.?.? / ????-??-?? +## 3.0.0 / 2021-10-21 + +* Implemented xp-framework/rfc#341, dropping compatibility with XP 9 + (@thekid) + ## 2.3.0 / 2021-09-11 * Merged PR #17 - Implement file uploads. The new `upload()` method in the diff --git a/composer.json b/composer.json index 8af8ffd..acff8bb 100755 --- a/composer.json +++ b/composer.json @@ -6,13 +6,13 @@ "description" : "REST Client", "keywords": ["module", "xp"], "require" : { - "xp-framework/core": "^10.0 | ^9.0 | ^8.0 | ^7.0", + "xp-framework/core": "^11.0 | ^10.0", "xp-framework/http": "^10.0 | ^9.1", - "xp-framework/logging": "^10.0 | ^9.0 | ^8.0 | ^7.0", + "xp-framework/logging": "^11.0 | ^10.0 | ^9.0 | ^8.0 | ^7.0", "xp-framework/tokenize": "^9.0 | ^8.0", - "xp-forge/json": "^4.0 | ^3.1", + "xp-forge/json": "^5.0 | ^4.0 | ^3.1", "xp-forge/uri": "^2.0 | ^1.3", - "xp-forge/marshalling": "^1.0 | ^0.3 | ^0.2", + "xp-forge/marshalling": "^1.0", "php": ">=7.0.0" }, "require-dev" : { diff --git a/src/main/php/webservices/rest/io/Buffered.class.php b/src/main/php/webservices/rest/io/Buffered.class.php index f7152ea..a353f87 100755 --- a/src/main/php/webservices/rest/io/Buffered.class.php +++ b/src/main/php/webservices/rest/io/Buffered.class.php @@ -7,7 +7,7 @@ class Buffered extends Transfer { public function headers($length) { return ['Content-Length' => $length]; } public function stream($request, $format, $value) { - $bytes= $format->serialize($value, new MemoryOutputStream())->getBytes(); + $bytes= $format->serialize($value, new MemoryOutputStream())->bytes(); $stream= $this->endpoint->open($request->with(['Content-Length' => strlen($bytes)])); $stream->write($bytes); return $stream; diff --git a/src/main/php/webservices/rest/io/Traced.class.php b/src/main/php/webservices/rest/io/Traced.class.php index ff2ac42..a4ec29d 100755 --- a/src/main/php/webservices/rest/io/Traced.class.php +++ b/src/main/php/webservices/rest/io/Traced.class.php @@ -53,7 +53,7 @@ public function finish() { public function writer($request, $format, $marshalling) { if ($payload= $request->payload()) { - $bytes= $format->serialize($marshalling->marshal($payload->value()), new MemoryOutputStream())->getBytes(); + $bytes= $format->serialize($marshalling->marshal($payload->value()), new MemoryOutputStream())->bytes(); $stream= $this->untraced->endpoint->open($request->with($this->untraced->headers(strlen($bytes)))); $stream->start(); diff --git a/src/test/php/webservices/rest/unittest/CookiesTest.class.php b/src/test/php/webservices/rest/unittest/CookiesTest.class.php index 42e7f03..4a6e890 100755 --- a/src/test/php/webservices/rest/unittest/CookiesTest.class.php +++ b/src/test/php/webservices/rest/unittest/CookiesTest.class.php @@ -78,7 +78,7 @@ public function cookies_without_value_erased() { #[Test] public function string_representation() { $cookies= new Cookies([ - new Cookie('session', '0x6100', ['Secure' => true]), + new Cookie('session', '0x6100', ['Secure' => true, 'HttpOnly' => true]), new Cookie('lang', 'de'), ]); @@ -87,6 +87,7 @@ public function string_representation() { " webservices.rest.Cookie(lang=de)@[]\n". " webservices.rest.Cookie(session=0x6100)@[\n". " Secure => true\n". + " HttpOnly => true\n". " ]\n". "}", $cookies->toString() diff --git a/src/test/php/webservices/rest/unittest/format/FormUrlencodedTest.class.php b/src/test/php/webservices/rest/unittest/format/FormUrlencodedTest.class.php index f8181b8..f96c2b9 100755 --- a/src/test/php/webservices/rest/unittest/format/FormUrlencodedTest.class.php +++ b/src/test/php/webservices/rest/unittest/format/FormUrlencodedTest.class.php @@ -15,7 +15,7 @@ public function can_create() { #[Test] public function serialize() { $format= new FormUrlencoded(); - Assert::equals('key=value', $format->serialize(['key' => 'value'], new MemoryOutputStream())->getBytes()); + Assert::equals('key=value', $format->serialize(['key' => 'value'], new MemoryOutputStream())->bytes()); } #[Test] diff --git a/src/test/php/webservices/rest/unittest/format/JsonTest.class.php b/src/test/php/webservices/rest/unittest/format/JsonTest.class.php index 3d92532..6e6aa47 100755 --- a/src/test/php/webservices/rest/unittest/format/JsonTest.class.php +++ b/src/test/php/webservices/rest/unittest/format/JsonTest.class.php @@ -14,12 +14,12 @@ public function can_create() { #[Test] public function serialize() { - Assert::equals('{"key":"value"}', (new Json())->serialize(['key' => 'value'], new MemoryOutputStream())->getBytes()); + Assert::equals('{"key":"value"}', (new Json())->serialize(['key' => 'value'], new MemoryOutputStream())->bytes()); } #[Test, Values([[[], '{}'], [['key' => 'value'], '{"key":"value"}'],])] public function serialize_object($map, $expected) { - Assert::equals($expected, (new Json())->serialize((object)$map, new MemoryOutputStream())->getBytes()); + Assert::equals($expected, (new Json())->serialize((object)$map, new MemoryOutputStream())->bytes()); } #[Test] diff --git a/src/test/php/webservices/rest/unittest/format/NdJsonTest.class.php b/src/test/php/webservices/rest/unittest/format/NdJsonTest.class.php index bcff1b7..376431f 100755 --- a/src/test/php/webservices/rest/unittest/format/NdJsonTest.class.php +++ b/src/test/php/webservices/rest/unittest/format/NdJsonTest.class.php @@ -15,17 +15,17 @@ public function can_create() { #[Test, Values([[['some', 'value'], "\"some\"\n\"value\"\n"], [[['key' => 'value']], "{\"key\":\"value\"}\n"], [[['key' => 'value'], ['other'=>'value']], "{\"key\":\"value\"}\n{\"other\":\"value\"}\n"],])] public function serialize($value, $expected) { - Assert::equals($expected, (new NdJson())->serialize(new \ArrayIterator($value), new MemoryOutputStream())->getBytes()); + Assert::equals($expected, (new NdJson())->serialize(new \ArrayIterator($value), new MemoryOutputStream())->bytes()); } #[Test, Values([[[], '{}'], [['key' => 'value'], '{"key":"value"}'],])] public function serialize_object($map, $expected) { - Assert::equals($expected, (new NdJson())->serialize((object)$map, new MemoryOutputStream())->getBytes()); + Assert::equals($expected, (new NdJson())->serialize((object)$map, new MemoryOutputStream())->bytes()); } #[Test, Values([[[], '[]'], [['key' => 'value'], '{"key":"value"}'],])] public function serialize_array($map, $expected) { - Assert::equals($expected, (new NdJson())->serialize($map, new MemoryOutputStream())->getBytes()); + Assert::equals($expected, (new NdJson())->serialize($map, new MemoryOutputStream())->bytes()); } #[Test, Values([["\"some\"\n\"value\"\n", ['some', 'value']], ['{"key":"value"}', [['key' => 'value']]], ["{\"key\":\"value\"}\n{\"other\":\"value\"}\n", [['key' => 'value'], ['other'=>'value']]],])]