Merge pull request 'fix(platform): document the methods of the gzip writer' (#166) from fix/lint-compress into main
This commit was merged in pull request #166.
This commit is contained in:
commit
9d01b62b98
1 file changed
+3
@@ -104,6 +104,7 @@ func (w *gzipWriter) decide() {
|
|||||||
w.gz.Reset(w.ResponseWriter)
|
w.gz.Reset(w.ResponseWriter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write compresses b if decide chose to, which it does at the first write.
|
||||||
func (w *gzipWriter) Write(b []byte) (int, error) {
|
func (w *gzipWriter) Write(b []byte) (int, error) {
|
||||||
if !w.decided {
|
if !w.decided {
|
||||||
if w.Header().Get("Content-Type") == "" {
|
if w.Header().Get("Content-Type") == "" {
|
||||||
@@ -117,10 +118,12 @@ func (w *gzipWriter) Write(b []byte) (int, error) {
|
|||||||
return w.gz.Write(b)
|
return w.gz.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteString writes s like Write, so strings are compressed as well.
|
||||||
func (w *gzipWriter) WriteString(s string) (int, error) {
|
func (w *gzipWriter) WriteString(s string) (int, error) {
|
||||||
return w.Write([]byte(s))
|
return w.Write([]byte(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flush sends what is compressed so far, for responses that stream.
|
||||||
func (w *gzipWriter) Flush() {
|
func (w *gzipWriter) Flush() {
|
||||||
if w.gz != nil {
|
if w.gz != nil {
|
||||||
_ = w.gz.Flush()
|
_ = w.gz.Flush()
|
||||||
|
|||||||
Reference in new issue
Block a user