metadata filetype -> Content-Type

parent 16e8d1e4
...@@ -84,20 +84,20 @@ static VCL_BOOL ...@@ -84,20 +84,20 @@ static VCL_BOOL
tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv, tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv,
struct tus_concat *c, struct tus_file_disk *fdisk) struct tus_concat *c, struct tus_file_disk *fdisk)
{ {
VCL_BLOB hash = NULL; VCL_BLOB b = NULL;
struct vsb vsb[1]; struct vsb vsb[1];
const char *slash; const char *p;
tus_body_assign(ctx->req, c); tus_body_assign(ctx->req, c);
http_ForceField(ctx->http_req, HTTP_HDR_METHOD, "PUT"); http_ForceField(ctx->http_req, HTTP_HDR_METHOD, "PUT");
if (fdisk->type == TUS_SINGLE) if (fdisk->type == TUS_SINGLE)
hash = tus_concat_hash(ctx, srv, c); b = tus_concat_hash(ctx, srv, c);
if (hash != NULL) { if (b != NULL) {
slash = strrchr(fdisk->url_path, '/'); p = strrchr(fdisk->url_path, '/');
AN(slash); AN(p);
WS_VSB_new(vsb, ctx->ws); WS_VSB_new(vsb, ctx->ws);
VSB_bcat(vsb, fdisk->url_path, (slash - fdisk->url_path) + 1); VSB_bcat(vsb, fdisk->url_path, (p - fdisk->url_path) + 1);
tus_vsbhex(vsb, hash); tus_vsbhex(vsb, b);
http_ForceField(ctx->http_req, HTTP_HDR_URL, http_ForceField(ctx->http_req, HTTP_HDR_URL,
WS_VSB_finish(vsb, ctx->ws, NULL)); WS_VSB_finish(vsb, ctx->ws, NULL));
} else { } else {
...@@ -107,6 +107,16 @@ tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv, ...@@ -107,6 +107,16 @@ tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv,
http_PrintfHeader(ctx->http_req, "Content-Length: %zu", http_PrintfHeader(ctx->http_req, "Content-Length: %zu",
fdisk->upload_length); fdisk->upload_length);
// https://github.com/tus/tus-resumable-upload-protocol/pull/160
http_Unset(ctx->http_req, H_Content_Type);
if (tus_file_meta(ctx, fdisk, "filetype", &b)) {
WS_VSB_new(vsb, ctx->ws);
VSB_bcat(vsb, b->blob, b->len);
VSB_putc(vsb, '\0');
p = WS_VSB_finish(vsb, ctx->ws, NULL);
if (validhdr(p))
http_ForceHeader(ctx->http_req, H_Content_Type, p);
}
// move to table? // move to table?
http_Unset(ctx->http_req, hdr_resum); http_Unset(ctx->http_req, hdr_resum);
http_Unset(ctx->http_req, hdr_vers); http_Unset(ctx->http_req, hdr_vers);
......
...@@ -15,6 +15,7 @@ server s2 { ...@@ -15,6 +15,7 @@ server s2 {
txresp txresp
expect req.method == PUT expect req.method == PUT
expect req.url == /vtc expect req.url == /vtc
expect req.http.Content-Type == application/pdf
expect req.bodylen == 100 expect req.bodylen == 100
} -start } -start
...@@ -151,7 +152,7 @@ client c2 { ...@@ -151,7 +152,7 @@ client c2 {
# partial Upload with create # partial Upload with create
txreq -method POST \ txreq -method POST \
-hdr "Upload-Metadata: filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential" \ -hdr "Upload-Metadata: filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential,filetype YXBwbGljYXRpb24vcGRm" \
-hdr "Upload-Length: 100" \ -hdr "Upload-Length: 100" \
-hdr "Tus-Resumable: 1.0.0" \ -hdr "Tus-Resumable: 1.0.0" \
-hdr "Content-Type: application/offset+octet-stream" \ -hdr "Content-Type: application/offset+octet-stream" \
...@@ -169,7 +170,7 @@ client c2 { ...@@ -169,7 +170,7 @@ client c2 {
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$" expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD? ## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential" expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential,filetype YXBwbGljYXRpb24vcGRm"
expect resp.http.Location == "http://localhost/vtc" expect resp.http.Location == "http://localhost/vtc"
expect resp.http.has-filename == true expect resp.http.has-filename == true
...@@ -199,7 +200,7 @@ client c2 { ...@@ -199,7 +200,7 @@ client c2 {
expect resp.http.Upload-Length == 100 expect resp.http.Upload-Length == 100
expect resp.http.Upload-Expires ~ "GMT$" expect resp.http.Upload-Expires ~ "GMT$"
## XXX only for HEAD? ## XXX only for HEAD?
expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential" expect resp.http.Upload-Metadata == "filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,is_confidential,filetype YXBwbGljYXRpb24vcGRm"
expect resp.http.has-filename == true expect resp.http.has-filename == true
expect resp.http.has-is_confidential == true expect resp.http.has-is_confidential == true
......
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