aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/lib
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2016-05-18 14:05:09 -0700
committerGravatar Stanley Cheung <stanleycheung@google.com>2016-06-14 11:00:15 -0700
commit6668d51b3c6544ab988a503977e0e80475ac5d3e (patch)
tree137ae8b6c6ff72fc927fbbbbdd0221f7ad3d6fab /src/php/lib
parenta47acad040242c03d5e812a40fd11225f327d45e (diff)
php: add call getTrailingMetadata API
Diffstat (limited to 'src/php/lib')
-rw-r--r--src/php/lib/Grpc/AbstractCall.php10
-rw-r--r--src/php/lib/Grpc/BidiStreamingCall.php1
-rw-r--r--src/php/lib/Grpc/ClientStreamingCall.php4
-rw-r--r--src/php/lib/Grpc/ServerStreamingCall.php1
-rw-r--r--src/php/lib/Grpc/UnaryCall.php4
5 files changed, 18 insertions, 2 deletions
diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php
index 712af91eb2..c86d298805 100644
--- a/src/php/lib/Grpc/AbstractCall.php
+++ b/src/php/lib/Grpc/AbstractCall.php
@@ -39,6 +39,7 @@ abstract class AbstractCall
protected $call;
protected $deserialize;
protected $metadata;
+ protected $trailing_metadata;
/**
* Create a new Call wrapper object.
@@ -66,6 +67,7 @@ abstract class AbstractCall
$this->call = new Call($channel, $method, $deadline);
$this->deserialize = $deserialize;
$this->metadata = null;
+ $this->trailing_metadata = null;
if (isset($options['call_credentials_callback']) &&
is_callable($call_credentials_callback =
$options['call_credentials_callback'])) {
@@ -84,6 +86,14 @@ abstract class AbstractCall
}
/**
+ * @return The trailing metadata sent by the server.
+ */
+ public function getTrailingMetadata()
+ {
+ return $this->trailing_metadata;
+ }
+
+ /**
* @return string The URI of the endpoint.
*/
public function getPeer()
diff --git a/src/php/lib/Grpc/BidiStreamingCall.php b/src/php/lib/Grpc/BidiStreamingCall.php
index bf813c12e7..95e51c5088 100644
--- a/src/php/lib/Grpc/BidiStreamingCall.php
+++ b/src/php/lib/Grpc/BidiStreamingCall.php
@@ -112,6 +112,7 @@ class BidiStreamingCall extends AbstractCall
OP_RECV_STATUS_ON_CLIENT => true,
]);
+ $this->trailing_metadata = $status_event->status->metadata;
return $status_event->status;
}
}
diff --git a/src/php/lib/Grpc/ClientStreamingCall.php b/src/php/lib/Grpc/ClientStreamingCall.php
index 500cfe0d7a..315a406735 100644
--- a/src/php/lib/Grpc/ClientStreamingCall.php
+++ b/src/php/lib/Grpc/ClientStreamingCall.php
@@ -86,6 +86,8 @@ class ClientStreamingCall extends AbstractCall
]);
$this->metadata = $event->metadata;
- return [$this->deserializeResponse($event->message), $event->status];
+ $status = $event->status;
+ $this->trailing_metadata = $status->metadata;
+ return [$this->deserializeResponse($event->message), $status];
}
}
diff --git a/src/php/lib/Grpc/ServerStreamingCall.php b/src/php/lib/Grpc/ServerStreamingCall.php
index da48523717..53599fe4ae 100644
--- a/src/php/lib/Grpc/ServerStreamingCall.php
+++ b/src/php/lib/Grpc/ServerStreamingCall.php
@@ -91,6 +91,7 @@ class ServerStreamingCall extends AbstractCall
OP_RECV_STATUS_ON_CLIENT => true,
]);
+ $this->trailing_metadata = $status_event->status->metadata;
return $status_event->status;
}
}
diff --git a/src/php/lib/Grpc/UnaryCall.php b/src/php/lib/Grpc/UnaryCall.php
index b57903d6d0..b114b771b8 100644
--- a/src/php/lib/Grpc/UnaryCall.php
+++ b/src/php/lib/Grpc/UnaryCall.php
@@ -75,6 +75,8 @@ class UnaryCall extends AbstractCall
OP_RECV_STATUS_ON_CLIENT => true,
]);
- return [$this->deserializeResponse($event->message), $event->status];
+ $status = $event->status;
+ $this->trailing_metadata = $status->metadata;
+ return [$this->deserializeResponse($event->message), $status];
}
}