summaryrefslogtreecommitdiff
path: root/src/pkg/compress/gzip/gzip.go
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-05-14 18:39:35 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-05-14 18:39:35 +0200
commitefcc50dfdc94c82ee0292bf71992ecb7c0123061 (patch)
tree17dca99d1dc7fc4e9fe49c2cf6a99d337d4c039f /src/pkg/compress/gzip/gzip.go
parent04b08da9af0c450d645ab7389d1467308cfc2db8 (diff)
downloadgolang-efcc50dfdc94c82ee0292bf71992ecb7c0123061.tar.gz
Imported Upstream version 1.1upstream/1.1
Diffstat (limited to 'src/pkg/compress/gzip/gzip.go')
-rw-r--r--src/pkg/compress/gzip/gzip.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/pkg/compress/gzip/gzip.go b/src/pkg/compress/gzip/gzip.go
index 3035dfffc..45558b742 100644
--- a/src/pkg/compress/gzip/gzip.go
+++ b/src/pkg/compress/gzip/gzip.go
@@ -28,7 +28,7 @@ type Writer struct {
Header
w io.Writer
level int
- compressor io.WriteCloser
+ compressor *flate.Writer
digest hash.Hash32
size uint32
closed bool
@@ -191,6 +191,28 @@ func (z *Writer) Write(p []byte) (int, error) {
return n, z.err
}
+// Flush flushes any pending compressed data to the underlying writer.
+//
+// It is useful mainly in compressed network protocols, to ensure that
+// a remote reader has enough data to reconstruct a packet. Flush does
+// not return until the data has been written. If the underlying
+// writer returns an error, Flush returns that error.
+//
+// In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH.
+func (z *Writer) Flush() error {
+ if z.err != nil {
+ return z.err
+ }
+ if z.closed {
+ return nil
+ }
+ if z.compressor == nil {
+ z.Write(nil)
+ }
+ z.err = z.compressor.Flush()
+ return z.err
+}
+
// Close closes the Writer. It does not close the underlying io.Writer.
func (z *Writer) Close() error {
if z.err != nil {