Merge remote-tracking branch 'origin/master' into micha

This commit is contained in:
Mischa ter Smitten 2017-02-03 21:53:08 +01:00
commit 03ee590f14
5 changed files with 35 additions and 12 deletions

View File

@ -120,7 +120,22 @@ install {
name = "Install tusd" name = "Install tusd"
roles { roles {
role = "{{{init.paths.roles_dir}}}/apt/1.4.0" role = "{{{init.paths.roles_dir}}}/apt/1.4.0"
apt_install = ["apg", "build-essential", "curl", "git-core", "htop", "iotop", "libpcre3", "logtail", "mlocate", "mtr", "psmisc", "telnet", "vim", "wget"] apt_install = [
"apg",
"build-essential",
"curl",
"git-core",
"htop",
"iotop",
"libpcre3",
"logtail",
"mlocate",
"mtr",
"psmisc",
"telnet",
"vim",
"wget"
]
} }
roles { roles {
role = "{{{init.paths.roles_dir}}}/unattended-upgrades/1.3.1" role = "{{{init.paths.roles_dir}}}/unattended-upgrades/1.3.1"
@ -185,7 +200,6 @@ setup {
} }
roles { roles {
role = "{{{init.paths.roles_dir}}}/fqdn/1.2.1" role = "{{{init.paths.roles_dir}}}/fqdn/1.2.1"
fqdn = "{{lookup('env', 'FREY_DOMAIN')}}"
} }
tasks { tasks {
file = "path=/mnt/tusd-data state=directory owner=www-data group=ubuntu mode=ug+rwX,o= recurse=yes" file = "path=/mnt/tusd-data state=directory owner=www-data group=ubuntu mode=ug+rwX,o= recurse=yes"

View File

@ -8,7 +8,7 @@ apt_upgrade: false
apt_dpkg_configure: true apt_dpkg_configure: true
apt_install_state: present apt_install_state: present
apt_clean: true apt_clean: true
apt_autoremove: true apt_autoremove: false
# ansistrano roles # ansistrano roles
ansistrano_shared_paths: ansistrano_shared_paths:
@ -29,3 +29,6 @@ hostname: "{{ fqdn.split('.')[0] }}"
nodejs_yarn: false nodejs_yarn: false
nodejs_npm_global_packages: nodejs_npm_global_packages:
- name: yarn - name: yarn
# unattended-upgrades
unattended_remove_unused_dependencies: true

View File

@ -118,6 +118,9 @@ func TestConcat(t *testing.T) {
Method: "POST", Method: "POST",
ReqHeader: map[string]string{ ReqHeader: map[string]string{
"Tus-Resumable": "1.0.0", "Tus-Resumable": "1.0.0",
// A space between `final;` and the first URL should be allowed due to
// compatibility reasons, even if the specification does not define
// it. Therefore this character is included in this test case.
"Upload-Concat": "final; http://tus.io/files/a /files/b/", "Upload-Concat": "final; http://tus.io/files/a /files/b/",
}, },
Code: http.StatusCreated, Code: http.StatusCreated,
@ -153,7 +156,7 @@ func TestConcat(t *testing.T) {
}, },
Code: http.StatusOK, Code: http.StatusOK,
ResHeader: map[string]string{ ResHeader: map[string]string{
"Upload-Concat": "final; http://tus.io/files/a http://tus.io/files/b", "Upload-Concat": "final;http://tus.io/files/a http://tus.io/files/b",
"Upload-Length": "10", "Upload-Length": "10",
"Upload-Offset": "10", "Upload-Offset": "10",
}, },
@ -178,7 +181,7 @@ func TestConcat(t *testing.T) {
Method: "POST", Method: "POST",
ReqHeader: map[string]string{ ReqHeader: map[string]string{
"Tus-Resumable": "1.0.0", "Tus-Resumable": "1.0.0",
"Upload-Concat": "final; http://tus.io/files/c", "Upload-Concat": "final;http://tus.io/files/c",
}, },
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
}).Run(handler, t) }).Run(handler, t)
@ -200,7 +203,7 @@ func TestConcat(t *testing.T) {
Method: "POST", Method: "POST",
ReqHeader: map[string]string{ ReqHeader: map[string]string{
"Tus-Resumable": "1.0.0", "Tus-Resumable": "1.0.0",
"Upload-Concat": "final; /files/huge", "Upload-Concat": "final;/files/huge",
}, },
Code: http.StatusRequestEntityTooLarge, Code: http.StatusRequestEntityTooLarge,
}).Run(handler, t) }).Run(handler, t)
@ -240,7 +243,7 @@ func TestConcat(t *testing.T) {
URL: "", URL: "",
ReqHeader: map[string]string{ ReqHeader: map[string]string{
"Tus-Resumable": "1.0.0", "Tus-Resumable": "1.0.0",
"Upload-Concat": "final; ", "Upload-Concat": "final;",
}, },
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
}).Run(handler, t) }).Run(handler, t)

View File

@ -294,7 +294,7 @@ func TestPost(t *testing.T) {
"Tus-Resumable": "1.0.0", "Tus-Resumable": "1.0.0",
"Upload-Length": "300", "Upload-Length": "300",
"Content-Type": "application/offset+octet-stream", "Content-Type": "application/offset+octet-stream",
"Upload-Concat": "final; http://tus.io/files/a http://tus.io/files/b", "Upload-Concat": "final;http://tus.io/files/a http://tus.io/files/b",
}, },
ReqBody: strings.NewReader("hello"), ReqBody: strings.NewReader("hello"),
Code: http.StatusForbidden, Code: http.StatusForbidden,

View File

@ -341,8 +341,11 @@ func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request)
if info.IsFinal { if info.IsFinal {
v := "final;" v := "final;"
for _, uploadID := range info.PartialUploads { for _, uploadID := range info.PartialUploads {
v += " " + handler.absFileURL(r, uploadID) v += handler.absFileURL(r, uploadID) + " "
} }
// Remove trailing space
v = v[:len(v)-1]
w.Header().Set("Upload-Concat", v) w.Header().Set("Upload-Concat", v)
} }
@ -782,7 +785,7 @@ func serializeMeta(meta map[string]string) string {
// Parse the Upload-Concat header, e.g. // Parse the Upload-Concat header, e.g.
// Upload-Concat: partial // Upload-Concat: partial
// Upload-Concat: final; http://tus.io/files/a /files/b/ // Upload-Concat: final;http://tus.io/files/a /files/b/
func parseConcat(header string) (isPartial bool, isFinal bool, partialUploads []string, err error) { func parseConcat(header string) (isPartial bool, isFinal bool, partialUploads []string, err error) {
if len(header) == 0 { if len(header) == 0 {
return return
@ -793,8 +796,8 @@ func parseConcat(header string) (isPartial bool, isFinal bool, partialUploads []
return return
} }
l := len("final; ") l := len("final;")
if strings.HasPrefix(header, "final; ") && len(header) > l { if strings.HasPrefix(header, "final;") && len(header) > l {
isFinal = true isFinal = true
list := strings.Split(header[l:], " ") list := strings.Split(header[l:], " ")