Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2020-09-09 09:23:02 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2020-09-21 13:53:18 +0300
commite0dc0e38b1ca181caa2e85df7561da36aef8054e (patch)
tree62f90b1cdc41917f51e1195dfffc051d676ed5ed /internal/serving/disk
parentb58d528f947b9f5440e163386a49f4d581290982 (diff)
Add zip package that implements vfs.Root
Adds a zip package capable of reading zip files from an httprange.Resource. It reads archive file contents into memory per archive that is requested from the vfs.Root. WIP: add simple test for archive reader WIP: fix build WIP: update archive test WIP: adding tests for archive WIP: print more info WIP: update zip file correct symlink WIP: use correct file Add bad symlink file to zip Update handling long symlinks update documentation and reorg code fix up stuff
Diffstat (limited to 'internal/serving/disk')
-rw-r--r--internal/serving/disk/reader.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go
index 350d036b..a0c0ed0d 100644
--- a/internal/serving/disk/reader.go
+++ b/internal/serving/disk/reader.go
@@ -194,10 +194,17 @@ func (reader *Reader) serveFile(ctx context.Context, w http.ResponseWriter, r *h
return err
}
+ w.Header().Set("Content-Type", contentType)
+
reader.fileSizeMetric.Observe(float64(fi.Size()))
- w.Header().Set("Content-Type", contentType)
- http.ServeContent(w, r, origPath, fi.ModTime(), file)
+ // Support SeekableFile if available
+ if rs, ok := file.(vfs.SeekableFile); ok {
+ http.ServeContent(w, r, origPath, fi.ModTime(), rs)
+ } else {
+ w.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10))
+ io.Copy(w, file)
+ }
return nil
}