Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-tus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-tus
Commits
c450444a
Unverified
Commit
c450444a
authored
Oct 18, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve tus_file_new error reporting
parent
746fa92c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
6 deletions
+77
-6
Makefile.am
src/Makefile.am
+2
-1
tus_file.c
src/tus_file.c
+20
-2
tus_file.h
src/tus_file.h
+2
-1
tus_request.c
src/tus_request.c
+10
-2
coverage.vtc
src/vtc/coverage.vtc
+43
-0
No files found.
src/Makefile.am
View file @
c450444a
...
...
@@ -16,7 +16,8 @@ TESTS = \
vtc/plain_cors.vtc
\
vtc/name_hash.vtc
\
vtc/expires.vtc
\
vtc/done.vtc
vtc/done.vtc
\
vtc/coverage.vtc
# ----------------------------------------
# ext vmods
...
...
src/tus_file.c
View file @
c450444a
...
...
@@ -887,7 +887,8 @@ tus_name_rnd(struct vsb *vsb)
/* under tus_server mtx to protect tus_files */
struct
tus_file_core
*
tus_file_new
(
VRT_CTX
,
struct
VPFX
(
tus_server
)
*
srv
,
enum
tus_f_type
type
,
const
char
*
url_path
,
const
char
*
id
,
const
char
*
metadata
)
const
char
*
url_path
,
const
char
*
id
,
const
char
*
metadata
,
unsigned
*
status
,
const
char
**
reason
)
{
struct
tus_file_core
*
fcore
;
struct
tus_file_disk
*
fdisk
=
NULL
;
...
...
@@ -898,6 +899,9 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
int
fd
;
size_t
l
;
AN
(
status
);
AN
(
reason
);
if
(
id
!=
NULL
)
{
while
(
*
id
==
'/'
)
id
++
;
...
...
@@ -913,6 +917,8 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
errno
=
ENAMETOOLONG
;
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"%s: path too long: %s"
,
tus_server_name
(
srv
),
url_path
);
*
status
=
400
;
*
reason
=
"Path too long"
;
return
(
NULL
);
}
...
...
@@ -920,6 +926,8 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
errno
=
ENAMETOOLONG
;
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"%s: metadata too long: %s"
,
tus_server_name
(
srv
),
metadata
);
*
status
=
400
;
*
reason
=
"Metadata too long"
;
return
(
NULL
);
}
...
...
@@ -936,6 +944,8 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"%s: mkostemp(%s) failed: %d (%s)"
,
tus_server_name
(
srv
),
VSB_data
(
vsb_path
),
errno
,
strerror
(
errno
));
*
status
=
500
;
*
reason
=
"mkostemp failed"
;
return
(
NULL
);
}
path
=
VSB_data
(
vsb_path
);
...
...
@@ -945,6 +955,8 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"%s: fallocate(%s) failed: %d (%s)"
,
tus_server_name
(
srv
),
path
,
errno
,
strerror
(
errno
));
*
status
=
500
;
*
reason
=
"fallocate failed"
;
goto
err
;
}
...
...
@@ -959,9 +971,12 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
fdisk
=
tus_mmap_header
(
fd
);
if
(
fdisk
==
NULL
)
{
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"%s: tus_mmap_header(%s) failed: %d (%s)"
,
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"%s: tus_mmap_header(%s) failed: %d (%s)"
,
tus_server_name
(
srv
),
path
,
errno
,
strerror
(
errno
));
*
status
=
500
;
*
reason
=
"mmap failed"
;
goto
err
;
}
...
...
@@ -995,6 +1010,9 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
/* undo. happens for clash with custom id */
AN
(
id
);
*
status
=
409
;
*
reason
=
"custom id clash"
;
err:
tus_file_disk_del
(
&
fdisk
,
&
fd
,
path
,
-
1
);
return
(
NULL
);
...
...
src/tus_file.h
View file @
c450444a
...
...
@@ -157,7 +157,8 @@ void tus_file_unlock(struct tus_file_core **);
void
tus_file_del
(
struct
tus_file_core
**
);
void
tus_file_exp
(
struct
tus_file_core
**
);
struct
tus_file_core
*
tus_file_new
(
VRT_CTX
,
struct
VPFX
(
tus_server
)
*
,
enum
tus_f_type
,
const
char
*
,
const
char
*
,
const
char
*
);
enum
tus_f_type
,
const
char
*
,
const
char
*
,
const
char
*
,
unsigned
*
,
const
char
**
);
struct
tus_file_core
*
tus_file_lookup
(
struct
VPFX
(
tus_server
)
*
,
const
char
*
);
unsigned
tus_body_to_file
(
VRT_CTX
,
struct
tus_file_core
*
);
void
tus_file_mmap
(
struct
tus_file_core
*
);
...
...
src/tus_request.c
View file @
c450444a
...
...
@@ -252,6 +252,7 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
VCL_BLOB
hash
;
AZ
(
r
->
s
.
status
);
AZ
(
r
->
s
.
reason
);
AZ
(
r
->
fcore
);
if
(
http_GetHdr
(
ctx
->
http_req
,
hdr_method
,
&
p
))
{
...
...
@@ -317,7 +318,8 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
tus_server_lock
(
tussrv
);
if
(
m
==
POST
)
{
r
->
fcore
=
tus_file_new
(
ctx
,
tussrv
,
type
,
url
,
id
,
metadata
);
r
->
fcore
=
tus_file_new
(
ctx
,
tussrv
,
type
,
url
,
id
,
metadata
,
&
r
->
s
.
status
,
&
r
->
s
.
reason
);
}
else
{
r
->
fcore
=
tus_file_lookup
(
tussrv
,
url
);
}
...
...
@@ -390,7 +392,13 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
}
if
(
r
->
fcore
==
NULL
)
{
r
->
s
.
status
=
(
m
==
POST
)
?
409
:
404
;
if
(
m
==
POST
)
{
// tus_file_new sets error
AN
(
r
->
s
.
status
);
AN
(
r
->
s
.
reason
);
}
else
{
r
->
s
.
status
=
404
;
}
return
(
0
);
}
...
...
src/vtc/coverage.vtc
0 → 100644
View file @
c450444a
varnishtest "test vmod-tus tus_file_new error reporting"
varnish v1 -vcl+backend {
import tus;
backend proforma none;
sub vcl_init {
new tmp = tus.server("http://localhost", max = 3145B);
}
sub vcl_recv {
if (tmp.recv(id=req.http.id)) {
return (fail);
} else {
return (synth(4200));
}
}
sub vcl_synth {
if (resp.status == 4200) {
tmp.synth();
return (deliver);
}
}
} -start
# dynamic file name complete post
client c1 {
txreq -method POST \
-hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \
-hdr "Upload-Metadata: filename 07aW824osNXRg2P+3d7kc3ecw0sZiO9Hz3frfncm34Yi/FN7ZtaEGyZ1wnqD3f0PfxvksMDbFhjZo0SLGNhQHENFmsPN0OWnINTvfrFTpXKJoynvd10pPjYomcWKhNsvjTvgrMPYo6/LTzIjAn5q1iVi2qASqSLv4aaBzo7laR8tbI2uLr2I5kC2pXHMv67Dt+lBvXdJt1WxVBhnfWKDVFLnH051irlpiX34VSKFi7q+oRM2/Dy/QXJCmjlWGK/ZtODK3X3CrRLzGCYAKMvo0R3jbj1AF8GStuB4Gp37g0vbU52iaQu7cNuUbH0PO9SmI0jRd8gQHEnwxUej1HhF3hs77tdSY3XcndmZ/czb/a7ypaemmVdEVTw4h2aGrJbX46e+AjA06KPEA2sWtyZ3Mb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l3UpXrcwcnwsNEFHe6mgfMKyYGuBdfOvvk7phUsNGKg1PDyWXPN0OiOqYw0yFD0SVBLXhHX+nFDQ7Jgw5sP/Z+7IZZVvU=" \
-bodylen 100
rxresp
expect resp.status == 400
expect resp.reason == "Metadata too long"
expect resp.http.Reason == resp.reason
expect resp.http.Tus-Resumable == "1.0.0"
expect resp.http.Tus-Version == "1.0.0"
expect resp.http.Tus-Extension == "creation,creation-with-upload,expiration,termination,concatenation"
expect resp.http.Tus-Checksum-Algorithm == <undef>
expect resp.http.Tus-Max-Size == 3145
} -run
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment