-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Support Range header end in lfs #11314
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
Conversation
@burbon Thanks for the PR. More Range supportUnfortunately, your proposed PR breaks the unspecfied end range option: Take a look at: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range There are a few others that could be useful to support too. TestsI wonder if you would be able to add a test into either:
gitea/integrations/git_test.go Lines 107 to 111 in 505e456
gitea/integrations/git_test.go Line 227 in 505e456
or
gitea/integrations/lfs_getobject_test.go Line 59 in 505e456
|
Codecov Report
@@ Coverage Diff @@
## master #11314 +/- ##
==========================================
+ Coverage 43.82% 43.83% +0.01%
==========================================
Files 607 607
Lines 86919 86926 +7
==========================================
+ Hits 38094 38106 +12
+ Misses 44117 44113 -4
+ Partials 4708 4707 -1
Continue to review full report at Codecov.
|
This is so Range tests could still use doLfs but without repeating not related tests
* implemented extraHeader * parametrized expectedStatus
Hi @zeripath |
Pressed the close button accidentally. |
Unfortunately the way you've changed the tests is not going to work. I'll have a think about how best to fix this. |
You would need to move the preamble: defer prepareTestEnv(t)()
setting.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
return
} to the start of each of those Test... functions. I would also remove the use of the Let's take an example of (at least what I call) a declarative test: func doAPICreateRepository(ctx APITestContext, empty bool, callback ...func(*testing.T, api.Repository)) func(*testing.T) {
return func(t *testing.T) {
createRepoOption := &api.CreateRepoOption{
AutoInit: !empty,
Description: "Temporary repo",
Name: ctx.Reponame,
Private: true,
Gitignores: "",
License: "WTFPL",
Readme: "Default",
}
req := NewRequestWithJSON(t, "POST", "/api/v1/user/repos?token="+ctx.Token, createRepoOption)
if ctx.ExpectedCode != 0 {
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
return
}
resp := ctx.Session.MakeRequest(t, req, http.StatusCreated)
var repository api.Repository
DecodeJSON(t, resp, &repository)
if len(callback) > 0 {
callback[0](t, repository)
}
}
} I can use gitea/integrations/ssh_key_test.go Lines 87 to 214 in dbb7497
In particular take a look at: gitea/integrations/ssh_key_test.go Lines 169 to 187 in 57b6f83
The style almost self-documents - it says exactly what it is testing and you can see how using these components you can build a progressively more complex test. A test that follows a simple story of what it is doing. (That's not to say these tests are bad - they're just not declarative and componentisable. Making these componentisable may not be sensible - I cannot at present imagine we would want to request specific ranges in other tests, but we should try to keep the componentised test namespace as clean as possible.) |
Signed-off-by: Andrew Thornton <[email protected]>
Thanks for fixing tests. There is no need to |
I think it's good practice to just return tbh |
Can't find it being used in golang src. Myself I found it a bit confusing, suggesting that code after |
* Initial support of end Range header option in lfs * Allow end range option to be unspecified * Declare toByte for consistency * Factor out content encoding tests from doLfs This is so Range tests could still use doLfs but without repeating not related tests * Add Range header test * implemented extraHeader * parametrized expectedStatus * Add more test cases of Range header * Fix S1030: should use resp.Body.String() * Add more tests for edge cases * Fix tests Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: zeripath <[email protected]>
Current implementation of Range header support in LFS only uses range start and ignores range end.
We have a use case where for media files we want to download a fixed range data including range end. This change is an attempt to allow it.