Commit 59497f49 authored by manas kashyap's avatar manas kashyap 💬

New upstream version 5.0.0+debian

parent a3a670ea
......@@ -2,6 +2,11 @@
Formerly known as 'gitlab-git-http-server'.
v 5.0.0
- Update httprs for broken range implementations !266
- Direct Upload for User Uploads !265
v 4.3.1
- Objectstorage ETag checking !263
......
......@@ -25,13 +25,15 @@ type MultipartClaims struct {
jwt.StandardClaims
}
func Accelerate(tempDir string, h http.Handler) http.Handler {
// TODO: for Object Store this will need a authorize call
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
localOnlyPreAuth := &api.Response{TempPath: tempDir}
type PreAuthorizer interface {
PreAuthorizeHandler(next api.HandleFunc, suffix string) http.Handler
}
func Accelerate(rails PreAuthorizer, h http.Handler) http.Handler {
return rails.PreAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *api.Response) {
s := &savedFileTracker{request: r}
HandleFileUploads(w, r, h, localOnlyPreAuth, s)
})
HandleFileUploads(w, r, h, a, s)
}, "/authorize")
}
func (s *savedFileTracker) ProcessFile(_ context.Context, fieldName string, file *filestore.FileHandler, _ *multipart.Writer) error {
......
package upload
import (
"net/http"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
)
// SkipRailsAuthorizer implements a fake PreAuthorizer that do not calls rails API and
// authorize each call as a local only upload to TempPath
type SkipRailsAuthorizer struct {
// TempPath is the temporary path for a local only upload
TempPath string
}
// PreAuthorizeHandler implements PreAuthorizer. It always grant the upload.
// The fake API response contains only TempPath
func (l *SkipRailsAuthorizer) PreAuthorizeHandler(next api.HandleFunc, _ string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next(w, r, &api.Response{TempPath: l.TempPath})
})
}
......@@ -145,7 +145,8 @@ func (u *Upstream) configureRoutes() {
sendurl.SendURL,
)
uploadAccelerateProxy := upload.Accelerate(path.Join(u.DocumentRoot, "uploads/tmp"), proxy)
uploadPath := path.Join(u.DocumentRoot, "uploads/tmp")
uploadAccelerateProxy := upload.Accelerate(&upload.SkipRailsAuthorizer{TempPath: uploadPath}, proxy)
ciAPIProxyQueue := queueing.QueueRequests("ci_api_job_requests", uploadAccelerateProxy, u.APILimit, u.APIQueueLimit, u.APIQueueTimeout)
ciAPILongPolling := builds.RegisterHandler(ciAPIProxyQueue, redis.WatchKey, u.APICILongPollingDuration)
......@@ -182,6 +183,9 @@ func (u *Upstream) configureRoutes() {
),
),
// Uploads
route("POST", projectPattern+`uploads\z`, upload.Accelerate(api, proxy)),
// For legacy reasons, user uploads are stored under the document root.
// To prevent anybody who knows/guesses the URL of a user-uploaded file
// from downloading it we make sure requests to /uploads/ do _not_ pass
......
......@@ -111,8 +111,15 @@ func (r *HttpReadSeeker) Read(p []byte) (n int, err error) {
//
// May return ErrRangeRequestsNotSupported, ErrInvalidRange or ErrContentHasChanged
func (r *HttpReadSeeker) ReadAt(p []byte, off int64) (n int, err error) {
var nn int
r.Seek(off, 0)
return r.Read(p)
for n < len(p) && err == nil {
nn, err = r.Read(p[n:])
n += nn
}
return
}
// Close closes the response body
......@@ -202,7 +209,12 @@ func (r *HttpReadSeeker) rangeRequest() error {
case http.StatusRequestedRangeNotSatisfiable:
return ErrInvalidRange
case http.StatusOK:
return ErrContentHasChanged
// some servers return 200 OK for bytes=0-
if r.pos > 0 ||
(etag != "" && etag != res.Header.Get("ETag")) {
return ErrContentHasChanged
}
fallthrough
case http.StatusPartialContent:
r.r = res.Body
return nil
......
......@@ -97,10 +97,12 @@
"revisionTime": "2017-08-26T09:06:48Z"
},
{
"checksumSHA1": "6TbprMZzwDk+SaW+JxdxvnauyDk=",
"checksumSHA1": "mb0MqzDyYEQMgh8+qwVm1RV4cxc=",
"path": "github.com/jfbus/httprs",
"revision": "32cf48c14a79f94eb3d8100efc00e773c5c8b160",
"revisionTime": "2017-11-08T13:45:55Z"
"revision": "7861a11508467e8d1575182d6456065e6402d8fc",
"revisionTime": "2018-06-14T10:08:21Z",
"version": "master",
"versionExact": "master"
},
{
"checksumSHA1": "oIkoHb8+rM5Etur5HhZVY/sDQKQ=",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment