mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-18 18:13:09 +00:00
Idiomatic fixes from previous PRs (#20)
* Various idiomatic feedback from PHP team * Additional fixes after debugging tests
This commit is contained in:
@@ -42,6 +42,6 @@ final class Headers {
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return array_merge($this->headers);
|
||||
return $this->headers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace AWS\CRT\HTTP;
|
||||
|
||||
use AWS\CRT\NativeResource;
|
||||
|
||||
use AWS\CRT\Internal\Encoding;
|
||||
|
||||
abstract class Message extends NativeResource {
|
||||
@@ -12,11 +11,11 @@ abstract class Message extends NativeResource {
|
||||
private $query;
|
||||
private $headers;
|
||||
|
||||
public function __construct($method, $path, $query = [], $headers = null) {
|
||||
public function __construct($method, $path, $query = [], $headers = []) {
|
||||
$this->method = $method;
|
||||
$this->path = $path;
|
||||
$this->query = $query;
|
||||
$this->headers = !is_null($headers) ? $headers : new Headers();
|
||||
$this->headers = new Headers($headers);
|
||||
$this->acquire(self::$crt->http_message_new_from_blob(self::marshall($this)));
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ abstract class Message extends NativeResource {
|
||||
$query = [];
|
||||
}
|
||||
|
||||
return new $class($method, $path, $query, $headers);
|
||||
return new $class($method, $path, $query, $headers->toArray());
|
||||
}
|
||||
|
||||
public function pathAndQuery() {
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
|
||||
namespace AWS\CRT\HTTP;
|
||||
|
||||
use AWS\CRT\IO\InputStream;
|
||||
|
||||
class Request extends Message {
|
||||
private $body_stream = null;
|
||||
|
||||
public function __construct($method, $path, $query = [], $headers = null, $body_stream = null) {
|
||||
public function __construct($method, $path, $query = [], $headers = [], $body_stream = null) {
|
||||
parent::__construct($method, $path, $query, $headers);
|
||||
if (!is_null($body_stream) && !($body_stream instanceof InputStream)) {
|
||||
throw \InvalidArgumentException('body_stream must be an ' . InputStream::class);
|
||||
}
|
||||
$this->body_stream = $body_stream;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user