mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
added Content-Disposition header to diff
This commit is contained in:
@@ -314,7 +314,8 @@ public class RepositoryResource
|
|||||||
{
|
{
|
||||||
output = new BrowserStreamingOutput(browser, revision, path);
|
output = new BrowserStreamingOutput(browser, revision, path);
|
||||||
|
|
||||||
String contentDispositionName = getContentDispositionName(path);
|
String contentDispositionName =
|
||||||
|
getContentDispositionNameFromPath(path);
|
||||||
|
|
||||||
response = Response.ok(output).header("Content-Disposition",
|
response = Response.ok(output).header("Content-Disposition",
|
||||||
contentDispositionName).build();
|
contentDispositionName).build();
|
||||||
@@ -372,8 +373,13 @@ public class RepositoryResource
|
|||||||
|
|
||||||
if (diffViewer != null)
|
if (diffViewer != null)
|
||||||
{
|
{
|
||||||
|
String name =
|
||||||
|
repository.getName().concat("-").concat(revision).concat(".diff");
|
||||||
|
String contentDispositionName = getContentDispositionName(name);
|
||||||
|
|
||||||
response = Response.ok(new DiffStreamingOutput(diffViewer, revision,
|
response = Response.ok(new DiffStreamingOutput(diffViewer, revision,
|
||||||
path)).build();
|
path)).header("Content-Disposition",
|
||||||
|
contentDispositionName).build();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -519,6 +525,20 @@ public class RepositoryResource
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getContentDispositionName(String name)
|
||||||
|
{
|
||||||
|
return "attachment; filename=\"".concat(name).concat("\"");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -527,7 +547,7 @@ public class RepositoryResource
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getContentDispositionName(String path)
|
private String getContentDispositionNameFromPath(String path)
|
||||||
{
|
{
|
||||||
String name = path;
|
String name = path;
|
||||||
int index = path.lastIndexOf("/");
|
int index = path.lastIndexOf("/");
|
||||||
@@ -537,7 +557,7 @@ public class RepositoryResource
|
|||||||
name = path.substring(0, index);
|
name = path.substring(0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "attachment; filename=\"".concat(name).concat("\"");
|
return getContentDispositionName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user