diff --git a/include/grpc++/stream.h b/include/grpc++/stream.h index 6da1be4e9fe..be518c61ed6 100644 --- a/include/grpc++/stream.h +++ b/include/grpc++/stream.h @@ -111,7 +111,6 @@ class ClientReader final : public ClientStreamingInterface, } } - virtual bool Read(R *msg) override { WaitForInitialMetadata(); CallOpBuffer buf; @@ -255,7 +254,14 @@ class ClientReaderWriter final : public ClientStreamingInterface, template class ServerReader final : public ReaderInterface { public: - explicit ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + CallOpBuffer buf; + ctx_->SendInitialMetadataIfNeeded(&buf); + call_->PerformOps(&buf); + return call_->cq()->Pluck(&buf); + } virtual bool Read(R* msg) override { CallOpBuffer buf; @@ -273,7 +279,14 @@ class ServerReader final : public ReaderInterface { template class ServerWriter final : public WriterInterface { public: - explicit ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + CallOpBuffer buf; + ctx_->SendInitialMetadataIfNeeded(&buf); + call_->PerformOps(&buf); + return call_->cq()->Pluck(&buf); + } virtual bool Write(const W& msg) override { CallOpBuffer buf; @@ -293,7 +306,14 @@ template class ServerReaderWriter final : public WriterInterface, public ReaderInterface { public: - explicit ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + CallOpBuffer buf; + ctx_->SendInitialMetadataIfNeeded(&buf); + call_->PerformOps(&buf); + return call_->cq()->Pluck(&buf); + } virtual bool Read(R* msg) override { CallOpBuffer buf;