Skip to content

Commit

Permalink
webdav: add Content-Type and fix status
Browse files Browse the repository at this point in the history
Motivation:

For HTTP Third-party copy, the status code should be 202 (Accepted), but
dCache currently returns 200 (OK).

The Content-Type of the response is also not defined.

Modification:

Update response to include a Content-Type and to set the 202 status code
once the transfer has been started.

Result:

dCache COPY response is more in keeping with other storage systems.

Target: master
Requires-notes: no
Requires-book: no
Patch: https://rb.dcache.org/r/11490
Acked-by: Dmitry Litvintsev
  • Loading branch information
paulmillar committed Jan 23, 2019
1 parent 4f29cba commit 4560d3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -406,7 +406,7 @@ private void processThirdPartyCopy(Request request, Response response)
"Error performing OpenId Connect Token Exchange");
}
} else {
Optional<String> error =_remoteTransfers.acceptRequest(response.getOutputStream(),
Optional<String> error =_remoteTransfers.acceptRequest(response,
request.getHeaders(), getSubject(), getRestriction(), path,
remote, credential, direction, isVerificationRequired(),
overwriteAllowed);
Expand Down
Expand Up @@ -21,6 +21,7 @@
import com.google.common.util.concurrent.ListenableFuture;
import eu.emi.security.authn.x509.X509Credential;
import io.milton.http.Response;
import io.milton.http.Response.Status;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.HttpConnection;
import org.slf4j.Logger;
Expand Down Expand Up @@ -221,7 +222,7 @@ public long getPerformanceMarkerPeroid()
* Start a transfer and block until that transfer is complete.
* @return a description of the error, if there was a problem.
*/
public Optional<String> acceptRequest(OutputStream out, Map<String,String> requestHeaders,
public Optional<String> acceptRequest(Response response, Map<String,String> requestHeaders,
Subject subject, Restriction restriction, FsPath path, URI remote,
Object credential, Direction direction, boolean verification,
boolean overwriteAllowed)
Expand All @@ -235,14 +236,16 @@ public Optional<String> acceptRequest(OutputStream out, Map<String,String> reque
? EnumSet.of(TransferFlag.REQUIRE_VERIFICATION)
: EnumSet.noneOf(TransferFlag.class);
ImmutableMap<String,String> transferHeaders = buildTransferHeaders(requestHeaders);
RemoteTransfer transfer = new RemoteTransfer(out, subject, restriction,
RemoteTransfer transfer = new RemoteTransfer(response.getOutputStream(), subject, restriction,
path, remote, credential, flags, transferHeaders, direction,
overwriteAllowed);

long id;

synchronized (_transfers) {
id = transfer.start();
response.setStatus(Status.SC_ACCEPTED);
response.setContentTypeHeader("text/perf-marker-stream");
_transfers.put(id, transfer);
}

Expand Down Expand Up @@ -334,7 +337,6 @@ public RemoteTransfer(OutputStream out, Subject subject, Restriction restriction
FsPath path, URI destination, @Nullable Object credential,
EnumSet<TransferFlag> flags, ImmutableMap<String,String> transferHeaders,
Direction direction, boolean overwriteAllowed)
throws ErrorResponseException
{
_subject = subject;
_restriction = restriction;
Expand Down

0 comments on commit 4560d3f

Please sign in to comment.