Browse Source

Add support for compression on the client (#707)

Motivation:

Compression support is an optional part of the gRPC specification but
ideally should be supported. Users have also requested this feature
(#611).

Since introducing compression without breaking API is difficult we
should do this before we tag 1.0.0.

Modifications:

- Add support for gzip and deflate compression on the client.
- Introduce new configuration for supporting compression.
- Add interop tests for the client.

Result:

Client supports compression.
George Barnett 6 years ago
parent
commit
c72845326b
2 changed files with 77 additions and 0 deletions
  1. 15 0
      Sources/CGRPCZlib/empty.c
  2. 62 0
      Sources/CGRPCZlib/include/CGRPCZlib.h

+ 15 - 0
Sources/CGRPCZlib/empty.c

@@ -0,0 +1,15 @@
+/*
+ * Copyright 2020, gRPC Authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

+ 62 - 0
Sources/CGRPCZlib/include/CGRPCZlib.h

@@ -0,0 +1,62 @@
+/*
+ * Copyright 2020, gRPC Authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef C_GRPC_ZLIB_H_
+#define C_GRPC_ZLIB_H_
+
+#include <zlib.h>
+
+static inline int CGRPCZlib_deflateInit2(z_streamp stream, int level, int method, int windowBits,
+                                         int memLevel, int strategy) {
+  return deflateInit2(stream, level, method, windowBits, memLevel, strategy);
+}
+
+static inline unsigned long CGRPCZlib_deflateBound(z_streamp strm, unsigned long sourceLen) {
+  return deflateBound(strm, sourceLen);
+}
+
+static inline int CGRPCZlib_deflate(z_streamp strm, int flush) {
+  return deflate(strm, flush);
+}
+
+static inline int CGRPCZlib_deflateReset(z_streamp strm) {
+  return deflateReset(strm);
+}
+
+static inline int CGRPCZlib_deflateEnd(z_streamp strm) {
+  return deflateEnd(strm);
+}
+
+static inline int CGRPCZlib_inflateInit2(z_streamp stream, int windowBits) {
+  return inflateInit2(stream, windowBits);
+}
+
+static inline int CGRPCZlib_inflate(z_streamp strm, int flush) {
+  return inflate(strm, flush);
+}
+
+static inline int CGRPCZlib_inflateReset(z_streamp strm) {
+  return inflateReset(strm);
+}
+
+static inline int CGRPCZlib_inflateEnd(z_streamp strm) {
+  return inflateEnd(strm);
+}
+
+static inline Bytef *CGRPCZlib_castVoidToBytefPointer(void *in) {
+  return (Bytef *) in;
+}
+
+#endif  // C_GRPC_ZLIB_H_