Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ServeStream with ServeContent #20903

Merged
merged 7 commits into from
Aug 25, 2022

Conversation

KN4CK3R
Copy link
Member

@KN4CK3R KN4CK3R commented Aug 21, 2022

PR from Discord

Replace ServeStream with ServeContent which enabled HTTP range support for downloads. Only the package registry and the repo archiver use ServeStream.

A possible downside may be that http.ServeContent uses the Seek method to get the length of the stream. Sadly there is no way to pass the size as parameter even if we know it.

@KN4CK3R KN4CK3R added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Aug 21, 2022
@KN4CK3R KN4CK3R added this to the 1.18.0 milestone Aug 21, 2022
@zeripath
Copy link
Contributor

I guess the question is if we think this is a significant slowdown because of this?

A possibility might be to use ServeFile to somehow avoid it if necessary.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 21, 2022
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 21, 2022
modules/timeutil/timestamp.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 21, 2022
Co-authored-by: delvh <dev.lh@web.de>
@KN4CK3R
Copy link
Member Author

KN4CK3R commented Aug 21, 2022

I guess the question is if we think this is a significant slowdown because of this?

Yes. The best solution is if https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/net/http/fs.go;drc=8d57f4dcef5d69a0a3f807afaa9625018569010b;bpv=1;bpt=1;l=221 would be exported. Then we could simply pass the content size and the seek would just occur if it is needed because of the http range header. It's just unnecessary work at the moment.

@zeripath
Copy link
Contributor

I wonder if we can instead refactor to use ServeFile instead but I'm not certain how worth it it would be

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@3d76d60). Click here to learn what that means.
The diff coverage is 92.85%.

@@           Coverage Diff           @@
##             main   #20903   +/-   ##
=======================================
  Coverage        ?   46.84%           
=======================================
  Files           ?      993           
  Lines           ?   136758           
  Branches        ?        0           
=======================================
  Hits            ?    64059           
  Misses          ?    64836           
  Partials        ?     7863           
Impacted Files Coverage Δ
routers/web/user/package.go 0.00% <0.00%> (ø)
services/packages/packages.go 48.95% <75.00%> (ø)
modules/context/context.go 66.45% <100.00%> (ø)
modules/timeutil/timestamp.go 100.00% <100.00%> (ø)
routers/api/packages/composer/api.go 100.00% <100.00%> (ø)
routers/api/packages/composer/composer.go 73.65% <100.00%> (ø)
routers/api/packages/conan/conan.go 59.73% <100.00%> (ø)
routers/api/packages/generic/generic.go 73.88% <100.00%> (ø)
routers/api/packages/helm/helm.go 61.14% <100.00%> (ø)
routers/api/packages/maven/maven.go 62.40% <100.00%> (ø)
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@techknowlogick techknowlogick merged commit dc0253b into go-gitea:main Aug 25, 2022
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 26, 2022
* upstream/main:
  Add whitespace removal inside template curly brackes (go-gitea#20853)
  Only show relevant repositories on explore page (go-gitea#19361)
  Replace `ServeStream` with `ServeContent` (go-gitea#20903)
  Update JS dependencies (go-gitea#20950)
  chore: remove broken gitea-format-imports (go-gitea#20952)
vsysoev pushed a commit to IntegraSDL/gitea that referenced this pull request Aug 28, 2022
* Replace ServeStream with ServeContent.

* Update modules/timeutil/timestamp.go

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
zeripath added a commit to zeripath/gitea that referenced this pull request Sep 4, 2022
Signed-off-by: Andrew Thornton <art27@cantab.net>
@KN4CK3R KN4CK3R deleted the refactor-servecontent branch October 17, 2022 07:00
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants