fixed gzip middleware not applying when serving static files
This commit is contained in:
		
							parent
							
								
									d92016af81
								
							
						
					
					
						commit
						ab7194a639
					
				| 
						 | 
					@ -1,3 +1,9 @@
 | 
				
			||||||
 | 
					## v0.23.3 (WIP)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Fixed Gzip middleware not applying when serving static files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## v0.23.2
 | 
					## v0.23.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Fixed `RecordQuery()` custom struct scanning ([#5958](https://github.com/pocketbase/pocketbase/discussions/5958)).
 | 
					- Fixed `RecordQuery()` custom struct scanning ([#5958](https://github.com/pocketbase/pocketbase/discussions/5958)).
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -221,23 +221,26 @@ func (w *gzipResponseWriter) Push(target string, opts *http.PushOptions) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *gzipResponseWriter) ReadFrom(r io.Reader) (n int64, err error) {
 | 
					// Note: Disable the implementation for now because in case the platform
 | 
				
			||||||
	if w.wroteHeader {
 | 
					// supports the sendfile fast-path it won't run gzipResponseWriter.Write,
 | 
				
			||||||
		w.ResponseWriter.WriteHeader(w.code)
 | 
					// preventing compression on the fly.
 | 
				
			||||||
	}
 | 
					//
 | 
				
			||||||
 | 
					// func (w *gzipResponseWriter) ReadFrom(r io.Reader) (n int64, err error) {
 | 
				
			||||||
	rw := w.ResponseWriter
 | 
					// 	if w.wroteHeader {
 | 
				
			||||||
	for {
 | 
					// 		w.ResponseWriter.WriteHeader(w.code)
 | 
				
			||||||
		switch rf := rw.(type) {
 | 
					// 	}
 | 
				
			||||||
		case io.ReaderFrom:
 | 
					// 	rw := w.ResponseWriter
 | 
				
			||||||
			return rf.ReadFrom(r)
 | 
					// 	for {
 | 
				
			||||||
		case router.RWUnwrapper:
 | 
					// 		switch rf := rw.(type) {
 | 
				
			||||||
			rw = rf.Unwrap()
 | 
					// 		case io.ReaderFrom:
 | 
				
			||||||
		default:
 | 
					// 			return rf.ReadFrom(r)
 | 
				
			||||||
			return io.Copy(w.ResponseWriter, r)
 | 
					// 		case router.RWUnwrapper:
 | 
				
			||||||
		}
 | 
					// 			rw = rf.Unwrap()
 | 
				
			||||||
	}
 | 
					// 		default:
 | 
				
			||||||
}
 | 
					// 			return io.Copy(w.ResponseWriter, r)
 | 
				
			||||||
 | 
					// 		}
 | 
				
			||||||
 | 
					// 	}
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *gzipResponseWriter) Unwrap() http.ResponseWriter {
 | 
					func (w *gzipResponseWriter) Unwrap() http.ResponseWriter {
 | 
				
			||||||
	return w.ResponseWriter
 | 
						return w.ResponseWriter
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue