rnewson commented on code in PR #6013:
URL: https://github.com/apache/couchdb/pull/6013#discussion_r3726997678
##########
src/couch_replicator/src/couch_replicator_api_wrap.erl:
##########
@@ -1052,6 +1068,32 @@ header_value(Key, Headers, Default) ->
_ ->
Default
end.
+
+%% Returns true if compression is enabled for HttpDb and Body is large enough.
+compress_requests(#httpdb{request_compression = ?COMPRESS_NONE}, _BodySize) ->
+ false;
+compress_requests(#httpdb{request_compression = ?COMPRESS_GZIP}, BodySize) ->
+ MinSize = config:get_integer("replicator", "compress_min_size",
?COMPRESS_MIN_SIZE),
+ BodySize >= MinSize;
+compress_requests(#httpdb{}, _BodySize) ->
+ false.
+
+%% Compress Body with gzip, prepend Content-Length and Content-Encoding
headers.
+%% Returns {CompressedBody, Headers}.
+gzip_request_body(Body, Headers) ->
+ Compressed = zlib:gzip(iolist_to_binary(Body)),
Review Comment:
zlib:gzip/1 takes iodata, so iolist_to_binary is unnecessary extra work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]