summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/zlib.n35
-rw-r--r--generic/tclZlib.c15
-rw-r--r--tests/zlib.test68
3 files changed, 102 insertions, 16 deletions
diff --git a/doc/zlib.n b/doc/zlib.n
index 2e08d71..ec3ea5a 100644
--- a/doc/zlib.n
+++ b/doc/zlib.n
@@ -277,10 +277,10 @@ the transformed data.
The full set of subcommands supported by a streaming instance command,
\fIstream\fR, is as follows:
.TP
-\fIstream \fBadd\fR ?\fIoption\fR? \fIdata\fR
+\fIstream \fBadd\fR ?\fIoption...\fR? \fIdata\fR
.
A short-cut for
-.QW "\fIstream \fBput \fIoption data\fR"
+.QW "\fIstream \fBput \fR?\fIoption...\fR? \fIdata\fR"
followed by
.QW "\fIstream \fBget\fR" .
.TP
@@ -325,14 +325,24 @@ Return the gzip header description dictionary extracted from the stream. Only
supported for streams created with their \fImode\fR parameter set to
\fBgunzip\fR.
.TP
-\fIstream \fBput\fR ?\fIoption\fR? \fIdata\fR
+\fIstream \fBput\fR ?\fIoption...\fR? \fIdata\fR
.
Append the contents of the binary string \fIdata\fR to \fIstream\fR's internal
-buffers while applying the transformation. If present, \fIoption\fR must be
-one of the following (or an unambiguous prefix) which are used to modify the
+buffers while applying the transformation. The following \fIoption\fRs are
+supported (or an unambiguous prefix of them), which are used to modify the
way in which the transformation is applied:
.RS
.TP
+\fB\-buffer\fI bufferSize\fR
+.
+\fITODO: document this\fR
+.TP
+\fB\-dictionary\fI compressionDictionary\fR
+.VS "TIP 400"
+Sets a compression dictionary to use when working with compressing or
+decompressing the data.
+.VE
+.TP
\fB\-finalize\fR
.
Mark the stream as finished, ensuring that all bytes have been wholly
@@ -340,12 +350,22 @@ compressed or decompressed. For gzip streams, this also ensures that the
footer is written to the stream. The stream will need to be reset before
having more data written to it after this, though data can still be read out
of the stream with the \fBget\fR subcommand.
+.RS
+.PP
+This option is mutually exclusive with the \fB\-flush\fR and \fB\-fullflush\fR
+options.
+.RE
.TP
\fB\-flush\fR
.
Ensure that a decompressor consuming the bytes that the current (compressing)
stream is producing will be able to produce all the bytes that have been
compressed so far, at some performance penalty.
+.RS
+.PP
+This option is mutually exclusive with the \fB\-finalize\fR and
+\fB\-fullflush\fR options.
+.RE
.TP
\fB\-fullflush\fR
.
@@ -353,6 +373,11 @@ Ensure that not only can a decompressor handle all the bytes produced so far
(as with \fB\-flush\fR above) but also that it can restart from this point if
it detects that the stream is partially corrupt. This incurs a substantial
performance penalty.
+.RS
+.PP
+This option is mutually exclusive with the \fB\-finalize\fR and \fB\-flush\fR
+options.
+.RE
.RE
.TP
\fIstream \fBreset\fR
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 333c2fa..22ab061 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -2350,10 +2350,10 @@ ZlibStreamCmd(
zs_fullflush, zs_get, zs_header, zs_put, zs_reset
};
static const char *const add_options[] = {
- "-buffer", "-finalize", "-flush", "-fullflush", NULL
+ "-buffer", "-dictionary", "-finalize", "-flush", "-fullflush", NULL
};
enum addOptions {
- ao_buffer, ao_finalize, ao_flush, ao_fullflush
+ ao_buffer, ao_dictionary, ao_finalize, ao_flush, ao_fullflush
};
if (objc < 2) {
@@ -2415,6 +2415,12 @@ ZlibStreamCmd(
NULL);
return TCL_ERROR;
}
+ break;
+ case ao_dictionary:
+ Tcl_AppendResult(interp,
+ "\"-dictionary\" option not implemented", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ZIP", "BADOPT", NULL);
+ return TCL_ERROR;
}
if (flush == -2) {
@@ -2474,6 +2480,11 @@ ZlibStreamCmd(
"\"-buffer\" option not supported here", NULL);
Tcl_SetErrorCode(interp, "TCL", "ZIP", "BADOPT", NULL);
return TCL_ERROR;
+ case ao_dictionary:
+ Tcl_AppendResult(interp,
+ "\"-dictionary\" option not implemented", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "ZIP", "BADOPT", NULL);
+ return TCL_ERROR;
}
if (flush == -2) {
Tcl_AppendResult(interp, "\"-flush\", \"-fullflush\" and "
diff --git a/tests/zlib.test b/tests/zlib.test
index ba21cd1..cfde1be 100644
--- a/tests/zlib.test
+++ b/tests/zlib.test
@@ -223,26 +223,76 @@ test zlib-8.7 {transformation and fconfigure} -setup {
catch {close $fd}
removeFile $file
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -translation lf -checksum 0} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -translation lf}}
+# Input is headers from fetching SPDY draft
+# Dictionary is that which is proposed _in_ SPDY draft
+set spdyHeaders "HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nX-Robots-Tag: noarchive\r\nLast-Modified: Tue, 05 Jun 2012 02:43:25 GMT\r\nETag: \"1338864205129|#public|0|en|||0\"\r\nExpires: Tue, 05 Jun 2012 16:17:11 GMT\r\nDate: Tue, 05 Jun 2012 16:17:06 GMT\r\nCache-Control: public, max-age=5\r\nX-Content-Type-Options: nosniff\r\nX-XSS-Protection: 1; mode=block\r\nServer: GSE\r\n"
+set spdyDict "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchif-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser-agent100101200201202203204205206300301302303304305306307400401402403404405406407408409410411412413414415416417500501502503504505accept-rangesageetaglocationproxy-authenticatepublicretry-afterservervarywarningwww-authenticateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertransfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locationcontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMondayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSepOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplication/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1.1statusversionurl"
test zlib-8.8 {transformtion and fconfigure} -setup {
lassign [chan pipe] inSide outSide
- # Input is headers from fetching SPDY draft
- # Dictionary is that which is proposed _in_ SPDY draft
- set msg "HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nX-Robots-Tag: noarchive\r\nLast-Modified: Tue, 05 Jun 2012 02:43:25 GMT\r\nETag: \"1338864205129|#public|0|en|||0\"\r\nExpires: Tue, 05 Jun 2012 16:17:11 GMT\r\nDate: Tue, 05 Jun 2012 16:17:06 GMT\r\nCache-Control: public, max-age=5\r\nX-Content-Type-Options: nosniff\r\nX-XSS-Protection: 1; mode=block\r\nServer: GSE\r\n"
- set dict "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchif-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser-agent100101200201202203204205206300301302303304305306307400401402403404405406407408409410411412413414415416417500501502503504505accept-rangesageetaglocationproxy-authenticatepublicretry-afterservervarywarningwww-authenticateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertransfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locationcontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMondayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSepOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplication/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1.1statusversionurl"
} -constraints zlib -body {
- zlib push compress $outSide -dictionary $dict
+ zlib push compress $outSide -dictionary $spdyDict
fconfigure $outSide -blocking 0 -translation binary -buffering none
fconfigure $inSide -blocking 0 -translation binary
- puts -nonewline $outSide $msg
+ puts -nonewline $outSide $spdyHeaders
chan pop $outSide
set compressed [read $inSide]
catch {zlib decompress $compressed} err opt
- list [string length [zlib deflate $msg]] [string length $compressed] \
- $err [dict get $opt -errorcode] [zlib adler32 $dict]
+ list [string length [zlib compress $spdyHeaders]] \
+ [string length $compressed] \
+ $err [dict get $opt -errorcode] [zlib adler32 $spdyDict]
} -cleanup {
catch {close $outSide}
catch {close $inSide}
-} -result {254 222 {need dictionary} {TCL ZLIB NEED_DICT 2381337010} 2381337010}
+} -result {260 222 {need dictionary} {TCL ZLIB NEED_DICT 2381337010} 2381337010}
+test zlib-8.9 {transformtion and fconfigure} -setup {
+ lassign [chan pipe] inSide outSide
+ set strm [zlib stream decompress]
+} -constraints zlib -body {
+ zlib push compress $outSide -dictionary $spdyDict
+ fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $inSide -blocking 0 -translation binary
+ puts -nonewline $outSide $spdyHeaders
+ chan pop $outSide
+ $strm put -dictionary $spdyDict [read $inSide]
+ list [string length $spdyHeaders] [string length [$strm get]]
+} -cleanup {
+ catch {close $outSide}
+ catch {close $inSide}
+ catch {$strm close}
+} -result {260 222}
+test zlib-8.10 {transformtion and fconfigure} -setup {
+ lassign [chan pipe] inSide outSide
+} -constraints zlib -body {
+ zlib push deflate $outSide -dictionary $spdyDict
+ fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $inSide -blocking 0 -translation binary
+ puts -nonewline $outSide $spdyHeaders
+ chan pop $outSide
+ set compressed [read $inSide]
+ catch {zlib inflate $compressed} err opt
+ list [string length [zlib deflate $spdyHeaders]] \
+ [string length $compressed] \
+ $err [dict get $opt -errorcode]
+} -cleanup {
+ catch {close $outSide}
+ catch {close $inSide}
+} -result {254 212 {data error} {TCL ZLIB DATA}}
+test zlib-8.11 {transformtion and fconfigure} -setup {
+ lassign [chan pipe] inSide outSide
+ set strm [zlib stream inflate]
+} -constraints zlib -body {
+ zlib push deflate $outSide -dictionary $spdyDict
+ fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $inSide -blocking 0 -translation binary
+ puts -nonewline $outSide $spdyHeaders
+ chan pop $outSide
+ $strm put -dictionary $spdyDict [read $inSide]
+ list [string length $spdyHeaders] [string length [$strm get]]
+} -cleanup {
+ catch {close $outSide}
+ catch {close $inSide}
+ catch {$strm close}
+} -result {260 222}
test zlib-9.1 "check fcopy with push" -constraints zlib -setup {
set sfile [makeFile {} testsrc.gz]