Skip to content

Commit

Permalink
Remove leftovers from older drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Jul 19, 2023
1 parent 1c14140 commit 379a1e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
9 changes: 0 additions & 9 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,5 @@ func NewHandler(config Config) (*Handler, error) {
mux.Del(":id", http.HandlerFunc(handler.DelFile))
}

if config.EnableTusV2 {
mux.Head("", http.HandlerFunc(handler.HeadFile))

// Only attach the DELETE handler if the Terminate() method is provided
if config.StoreComposer.UsesTerminater {
mux.Del("", http.HandlerFunc(handler.DelFile))
}
}

return routedHandler, nil
}
18 changes: 6 additions & 12 deletions pkg/handler/unrouted_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
r.Method = newMethod
}

// TODO: Handle Upload-Draft-Interop-Version

handler.log("RequestIncoming", "method", r.Method, "path", r.URL.Path, "requestId", getRequestId(r))

handler.Metrics.incRequestsTotal(r.Method)
Expand Down Expand Up @@ -290,7 +292,8 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
// PostFile creates a new file upload using the datastore after validating the
// length and parsing the metadata.
func (handler *UnroutedHandler) PostFile(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Upload-Incomplete") != "" {
isTusV2Request := r.Header.Get("Upload-Incomplete") != ""
if isTusV2Request {
handler.PostFileV2(w, r)
return
}
Expand Down Expand Up @@ -486,7 +489,8 @@ func (handler *UnroutedHandler) PostFileV2(w http.ResponseWriter, r *http.Reques
url := handler.absFileURL(r, id)
w.Header().Set("Location", url)

// TODO: Send 104 response
// Send 104 response
w.WriteHeader(104)

handler.Metrics.incUploadsCreated()

Expand Down Expand Up @@ -1181,10 +1185,6 @@ func (handler *UnroutedHandler) sendProgressMessages(hook HookEvent, reader *bod
}

func (handler *UnroutedHandler) extractUploadID(r *http.Request) (string, error) {
if isTusV2Request(r) {
return r.Header.Get("Upload-Token"), nil
}

return extractIDFromPath(r.URL.Path)
}

Expand Down Expand Up @@ -1422,9 +1422,3 @@ func getRequestId(r *http.Request) string {

return reqId
}

// isTusV2Request returns whether a HTTP request includes a sign that it is
// related to tus v2 (instead of tus v1)
func isTusV2Request(r *http.Request) bool {
return r.Header.Get("Upload-Token") != ""
}

0 comments on commit 379a1e6

Please sign in to comment.