@@ -12,7 +12,6 @@ import (
1212 "os"
1313 "path/filepath"
1414 "sync"
15- "time"
1615
1716 "golang.org/x/sync/errgroup"
1817 "golang.org/x/sync/singleflight"
@@ -217,7 +216,8 @@ func (s *LocalDirV1) handleV1All(w http.ResponseWriter, r *http.Request) {
217216 httpError (w , err )
218217 return
219218 }
220- serveJSONLines (w , r , catalogStat .ModTime (), catalogFile )
219+ w .Header ().Add ("Content-Type" , "application/jsonl" )
220+ http .ServeContent (w , r , "" , catalogStat .ModTime (), catalogFile )
221221}
222222
223223func (s * LocalDirV1 ) handleV1Query (w http.ResponseWriter , r * http.Request ) {
@@ -244,7 +244,8 @@ func (s *LocalDirV1) handleV1Query(w http.ResponseWriter, r *http.Request) {
244244
245245 if schema == "" && pkg == "" && name == "" {
246246 // If no parameters are provided, return the entire catalog (this is the same as /api/v1/all)
247- serveJSONLines (w , r , catalogStat .ModTime (), catalogFile )
247+ w .Header ().Add ("Content-Type" , "application/jsonl" )
248+ http .ServeContent (w , r , "" , catalogStat .ModTime (), catalogFile )
248249 return
249250 }
250251 idx , err := s .getIndex (catalog )
@@ -253,7 +254,7 @@ func (s *LocalDirV1) handleV1Query(w http.ResponseWriter, r *http.Request) {
253254 return
254255 }
255256 indexReader := idx .Get (catalogFile , schema , pkg , name )
256- serveJSONLinesQuery (w , r , indexReader )
257+ serveJSONLines (w , r , indexReader )
257258}
258259
259260func (s * LocalDirV1 ) catalogData (catalog string ) (* os.File , os.FileInfo , error ) {
@@ -283,12 +284,7 @@ func httpError(w http.ResponseWriter, err error) {
283284 http .Error (w , fmt .Sprintf ("%d %s" , code , http .StatusText (code )), code )
284285}
285286
286- func serveJSONLines (w http.ResponseWriter , r * http.Request , modTime time.Time , rs io.ReadSeeker ) {
287- w .Header ().Add ("Content-Type" , "application/jsonl" )
288- http .ServeContent (w , r , "" , modTime , rs )
289- }
290-
291- func serveJSONLinesQuery (w http.ResponseWriter , r * http.Request , rs io.Reader ) {
287+ func serveJSONLines (w http.ResponseWriter , r * http.Request , rs io.Reader ) {
292288 w .Header ().Add ("Content-Type" , "application/jsonl" )
293289 // Copy the content of the reader to the response writer
294290 // only if it's a Get request
0 commit comments