send "done" location as Content-Location for non-301

see https://httpwg.org/specs/rfc7231.html#header.content-location
parent 43c292fc
......@@ -8,6 +8,7 @@ const char * const hdr_max = "\015Tus-Max-Size:";
const char * const hdr_defer = "\024Upload-Defer-Length:";
const char * const hdr_meta = "\020Upload-Metadata:";
const char * const hdr_exp = "\017Upload-Expires:";
const char * const hdr_cloc = "\021Content-Location:";
const char * const hdr_loc = "\011Location:";
const char * const hdr_method = "\027X-HTTP-Method-Override:";
const char * const hdr_off = "\016Upload-Offset:";
......
......@@ -8,6 +8,7 @@ const char * const hdr_max;
const char * const hdr_defer;
const char * const hdr_meta;
const char * const hdr_exp;
const char * const hdr_cloc;
const char * const hdr_loc;
const char * const hdr_method;
const char * const hdr_off;
......
#include "config.h"
#include <sys/statvfs.h>
#include <stdio.h>
#include <cache/cache.h>
#include <vrt_obj.h>
......@@ -57,7 +58,7 @@ tus_cors(VCL_HTTP r, unsigned status, const char *origin)
http_ForceHeader(r, hdr_acma, "86400");
} else {
http_ForceHeader(r, hdr_aceh,
"Upload-Offset, Location, Upload-Length, Tus-Version, "
"Upload-Offset, Content-Location, Location, Upload-Length, Tus-Version, "
"Tus-Resumable, Tus-Max-Size, Tus-Extension, "
"Upload-Metadata, Upload-Defer-Length, Upload-Concat");
}
......@@ -72,6 +73,8 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
const char *chksums = tus_checksums();
VCL_HTTP r;
char t[VTIM_FORMAT_SIZE];
const char *loc;
char buf[TUS_PATH_MAX];
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
......@@ -93,15 +96,20 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
http_Unset(r, hdr_meta);
http_Unset(r, hdr_exp);
http_Unset(r, hdr_loc);
http_Unset(r, hdr_cloc);
if (fdisk != NULL && fdisk->location_length > 0) {
/* cannot happen for creation */
assert(resp->status != 201);
if (fdisk->location[0] == '/')
http_PrintfHeader(r, "Location: %s%s", resp->schemeauth,
fdisk->location);
else
http_ForceHeader(r, hdr_loc, fdisk->location);
if (fdisk->location[0] == '/') {
bprintf(buf, "%s%s", resp->schemeauth, fdisk->location);
loc = buf;
} else {
loc = fdisk->location;
}
http_ForceHeader(r,
resp->status == 301 ? hdr_loc : hdr_cloc,
loc);
}
if (resp->status == 301) {
......
......@@ -167,11 +167,12 @@ $Method BOOL .done([STRING location])
Mark the upload as done. For simple (non concat) uploads, this frees
all storage except for information on the upload URL itself.
If the optional *location* string is provided, a ``Location:``
If the optional *location* string is provided, a ``Content-Location:``
response header with that location will be added to all future
responses querying the object.
For any ``GET`` access, a 301 response will be generated.
For any ``GET`` access, a 301 response with the *location* in the
``Location:`` response header is generated.
May only be called from client methods. For anything but final concat
or single (non-concat) uploads, this operation is a noop.
......
......@@ -89,7 +89,7 @@ client c1 {
expect resp.http.Upload-Offset == 386550
expect resp.http.Upload-Length == 386550
expect resp.http.Upload-Expires ~ "GMT$"
expect resp.http.Location == "http://localhost/id"
expect resp.http.Content-Location == "http://localhost/id"
txreq -url "/id" \
-hdr "Tus-Resumable: 1.0.0"
......
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