Skip to content

Commit

Permalink
Drop support for XP < 9
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 21, 2021
1 parent b958ece commit 0281aba
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/webservices/rest/io/Buffered.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/webservices/rest/io/Traced.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion src/test/php/webservices/rest/unittest/CookiesTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']]],])]
Expand Down

0 comments on commit 0281aba

Please sign in to comment.