http2_client.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. *
  3. * Copyright 2016 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H
  19. #define GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H
  20. #include <memory>
  21. #include <grpc/grpc.h>
  22. #include <grpcpp/channel.h>
  23. #include "src/proto/grpc/testing/messages.pb.h"
  24. #include "src/proto/grpc/testing/test.grpc.pb.h"
  25. namespace grpc {
  26. namespace testing {
  27. class Http2Client {
  28. public:
  29. explicit Http2Client(const std::shared_ptr<Channel>& channel);
  30. ~Http2Client() {}
  31. bool DoRstAfterHeader();
  32. bool DoRstAfterData();
  33. bool DoRstDuringData();
  34. bool DoGoaway();
  35. bool DoPing();
  36. bool DoMaxStreams();
  37. private:
  38. class ServiceStub {
  39. public:
  40. explicit ServiceStub(const std::shared_ptr<Channel>& channel);
  41. TestService::Stub* Get();
  42. private:
  43. std::unique_ptr<TestService::Stub> stub_;
  44. std::shared_ptr<Channel> channel_;
  45. };
  46. void MaxStreamsWorker(const std::shared_ptr<grpc::Channel>& channel);
  47. bool AssertStatusCode(const Status& s, StatusCode expected_code);
  48. Status SendUnaryCall(SimpleResponse* response);
  49. SimpleRequest BuildDefaultRequest();
  50. ServiceStub serviceStub_;
  51. std::shared_ptr<Channel> channel_;
  52. SimpleRequest defaultRequest_;
  53. };
  54. } // namespace testing
  55. } // namespace grpc
  56. #endif // GRPC_TEST_CPP_INTEROP_HTTP2_CLIENT_H