fileName bug fix according to section 19.5.1 of RFC 2616

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@122565 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-01-27 14:13:34 +00:00
parent 98e540a756
commit 49cae260dd
2 changed files with 44 additions and 40 deletions

View File

@ -110,9 +110,12 @@ public class HttpResolver extends HttpServlet {
OutputStream out = response.getOutputStream();
if (fileName != null)
response.addHeader("content-disposition", "attachment; filename=" +fileName);
else
if (fileName != null){
//The filename should be a quoted string. (According to Section 19.5.1 of RFC 2616)
//http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
response.setHeader(ConstantsHttpResolver.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"");
// response.addHeader("content-disposition", "attachment; filename=" +fileName);
}else
response.addHeader("content-disposition", "attachment; filename="+ConstantsHttpResolver.DEFAULT_FILENAME_FROM_STORAGE_MANAGER);
if (contentType!= null)
@ -132,7 +135,7 @@ public class HttpResolver extends HttpServlet {
URLConnection uc = null;
try {
uc = ( URLConnection ) url.openConnection();
uc = url.openConnection();
in = uc.getInputStream();
}
catch(Exception e){

View File

@ -3,7 +3,6 @@ package org.gcube.datatransfer.resolver.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@ -148,7 +147,9 @@ public class StorageIDResolver extends HttpServlet {
if(contentType==null || contentType.isEmpty())
contentType = ConstantsHttpResolver.DEFAULT_CONTENTTYPE_UNKNOWN_UNKNOWN;
response.addHeader(ConstantsHttpResolver.CONTENT_DISPOSITION, "attachment; filename=" +URLEncoder.encode(fileName, "UTF-8"));
//The filename should be a quoted string. (According to Section 19.5.1 of RFC 2616)
//http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
response.setHeader(ConstantsHttpResolver.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"");
response.setContentType(contentType);
//CASE VALIDATION