Project

General

Profile

Feature #13020

Zlib.gzip and Zlib.gunzip

Added by naruse (Yui NARUSE) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:78565]

Description

I added Zlib.deflate/inflate [Feature #4180] before, but writing/reading gzip is still too complex.
It should have shorthand method.


Related issues

Related to Ruby master - Bug #13021: `Zlib.gunzip` modifies argument StringClosedActions

Associated revisions

Revision 583b6dc3
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip and Zlib.gunzip [Feature #13020]

Encode and Decode gzip data without creating files.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57035
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip and Zlib.gunzip [Feature #13020]

Encode and Decode gzip data without creating files.

Revision 57035
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip and Zlib.gunzip [Feature #13020]

Encode and Decode gzip data without creating files.

Revision 57035
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip and Zlib.gunzip [Feature #13020]

Encode and Decode gzip data without creating files.

Revision 57035
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip and Zlib.gunzip [Feature #13020]

Encode and Decode gzip data without creating files.

Revision ba568c0e
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip uses kwargs instead of argc [Feature #13020]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57126
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip uses kwargs instead of argc [Feature #13020]

Revision 57126
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip uses kwargs instead of argc [Feature #13020]

Revision 57126
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip uses kwargs instead of argc [Feature #13020]

Revision 57126
Added by naruse (Yui NARUSE) over 2 years ago

Zlib.gzip uses kwargs instead of argc [Feature #13020]

Revision 0adce993
Added by nobu (Nobuyoshi Nakada) over 2 years ago

rdoc for r57126 [ci skip]

  • ext/zlib/zlib.c: [DOC] update as keyword arguments. [Feature #13020]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57129
Added by nobu (Nobuyoshi Nakada) over 2 years ago

rdoc for r57126 [ci skip]

  • ext/zlib/zlib.c: [DOC] update as keyword arguments. [Feature #13020]

Revision 57129
Added by nobu (Nobuyoshi Nakada) over 2 years ago

rdoc for r57126 [ci skip]

  • ext/zlib/zlib.c: [DOC] update as keyword arguments. [Feature #13020]

Revision 57129
Added by nobu (Nobuyoshi Nakada) over 2 years ago

rdoc for r57126 [ci skip]

  • ext/zlib/zlib.c: [DOC] update as keyword arguments. [Feature #13020]

Revision 57129
Added by nobu (Nobuyoshi Nakada) over 2 years ago

rdoc for r57126 [ci skip]

  • ext/zlib/zlib.c: [DOC] update as keyword arguments. [Feature #13020]

History

#1

Updated by naruse (Yui NARUSE) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset r57035.


Zlib.gzip and Zlib.gunzip [Feature #13020]

Encode and Decode gzip data without creating files.

Updated by normalperson (Eric Wong) over 2 years ago

naruse@airemix.jp wrote:

I added Zlib.deflate/inflate [Feature #4180] before, but writing/reading gzip is still too complex.
It should have shorthand method.

I like the convenience, but I think encouraging use of
potentially large String buffers is dangerous.

It causes memory problems and even opens up DoS attacks.

So, I think it would be better if it used IO-like object
instead, to discourage slurping.

Maybe make it like IO.copy_stream:

Zlib.gzip(src_io, dst_io)
Zlib.gunzip(src_io, dst_io)

Slurpers can still use StringIO if they want to.

In general, I am against non-streaming APIs and want to
encourage processing data in predictable sizes to avoid
fragmentation and OOM.

#3

Updated by znz (Kazuhiro NISHIYAMA) over 2 years ago

  • Related to Bug #13021: `Zlib.gunzip` modifies argument String added

Updated by naruse (Yui NARUSE) over 2 years ago

Eric Wong wrote:

naruse@airemix.jp wrote:

I added Zlib.deflate/inflate [Feature #4180] before, but writing/reading gzip is still too complex.
It should have shorthand method.

I like the convenience, but I think encouraging use of
potentially large String buffers is dangerous.

It causes memory problems and even opens up DoS attacks.

So, I think it would be better if it used IO-like object
instead, to discourage slurping.

Maybe make it like IO.copy_stream:

Zlib.gzip(src_io, dst_io)
Zlib.gunzip(src_io, dst_io)

Slurpers can still use StringIO if they want to.

In general, I am against non-streaming APIs and want to
encourage processing data in predictable sizes to avoid
fragmentation and OOM.

There's already Zlib.deflate/inflate, which are memory based API.
And gzip also uses deflate/inflate.
Note that gzip has the length of original data at the end of data. (isize=origsize / (232))

Anyway IO.copy_stream like API sounds reasonable.
Current API needs to change interface to use keyword arguments to avoid using 2nd argument...

Also available in: Atom PDF