IE8 + SSL 버그로 인하여 다운로드 안될 때.
IE8 브라우저에서 HTTPS url로 파일 다운로드 요청시
이 인터넷 사이트를 열 수 없습니다. 요청한 사이트를 사용할 수 없거나 찾을 수 없습니다
뜰때는 아래와 같이 cache 부분을 public 으로 고쳐주면 된다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@RequestMapping(value=”/***/FileDown.do”,method=RequestMethod.GET)
public void downloadMediaFile(@RequestParam(“subpath”) String subpath,
HttpServletResponse response,
HttpServletRequest request) throws Exception {
String downFileName = docDir + subpath;
String filename = subpath; //폴더 구조 변경시 error
String downloadUrl = ””;
String[] arrFilename;
arrFilename = filename.split(“/”);
filename = arrFilename[arrFilename.length - 1];
downloadUrl = arrFilename[1];
//파일 경로중 첫번째가 download여야 한다.
if(!downloadUrl.equals(“uploadfiles”)){
response.sendRedirect(“/error/500.do”);
return;
}
//System.out.println(“—————– downloadurl ” + downloadUrl + ” downFileName ” + downFileName);
File file = new File(EgovWebUtil.filePathBlackList(downFileName));
if (!file.exists()) {
throw new FileNotFoundException(downFileName);
}
if (!file.isFile()) {
throw new FileNotFoundException(downFileName);
}
String refilename = new String(filename.getBytes(“MS949”),”8859_1”);
System.out.println(“refilename = ” + refilename);
response.setContentType(“application/octet-stream”);
/추가사항 20140311 ie 버그 /
boolean ieSSLBug = false;
String userAgent = EgovStringUtil.nvl(request.getHeader(“User-Agent”), ””);
| if (userAgent.indexOf(“MSIE 6”) > -1 | userAgent.indexOf(“MSIE 7”) > -1 | userAgent.indexOf(“MSIE 8”) > -1) { |
ieSSLBug = true;
}
String noCache =””;
if(ieSSLBug){
//noCache=”no-cache, ”;
noCache =”public, ”;**
}
response.setHeader(“Cache-Control”, noCache + ”no-store”);
response.setHeader(“Content-Disposition”, ”attachment; filename="“ + refilename + ”";”);
response.setHeader(“Content-Transfer-Encoding”, ”binary”);
response.setHeader(“Pragma”, noCache);
response.setHeader(“Expires”, ”0”);
BufferedInputStream fin = null;
BufferedOutputStream outs = null;
byte[] b = new byte[BUFFER_SIZE];
try {
fin = new BufferedInputStream(new FileInputStream(file));
outs = new BufferedOutputStream(response.getOutputStream());
int read = 0;
for(read = fin.read(b); read != -1; read = fin.read(b)){
outs.write(b, 0, read);
}
/*
while ((read = fin.read(b)) != -1) {
outs.write(b, 0, read);
}
*/
}catch(RuntimeException e){
throw new UnknownErrorException(“file download Error!!”);
}catch(Exception e){
//e.printStackTrace();
throw new UnknownErrorException(“file download Error!!”);
}finally {
if (outs != null) {
try { // 2012.11 KISA 보안조치
outs.close();
}catch(RuntimeException e){
throw new UnknownErrorException(“file download Error!!”);
} catch (Exception ignore) {
// no-op
throw new UnknownErrorException(“file download Error!!”);
}
}
if (fin != null) {
try { // 2012.11 KISA 보안조치
fin.close();
}catch(RuntimeException e){
throw new UnknownErrorException(“file download Error!!”);
} catch (Exception ignore) {
// no-op
throw new UnknownErrorException(“file download Error!!”);
}
}
}
}