代码改变世界

Firefox浏览器中,Flex的FileReference上传文件,引发IOError

2012-07-10 12:47  fangzhao.lee  阅读(470)  评论(0编辑  收藏  举报

1. I use Tomcat with realm auhentication (based on cookies) 
2. I use URLLoader to get some XML data with Struts Action handlers 
    it is usual to set headers to disable cache in the browser like this: 
             response.setHeader("Cache-Control","no-store"); // for HTTP1.1 
             response.setHeader("Pragma","no-cache"); // for HTTP 1.0 
             response.setDateHeader ("Expires", 0); // for proxy 

3. I use FileReference to upload a file 
  
 Actual Results: 
- when Tomcat set "Pragma: no-cache" on url used by URLLoader, FileReference won't work when I upload a file 
- When I force to an empy string: "Pragma: ", FileRerence work ! 
  note: I created a J2EE filter to set the header like this: 

response.setHeader("Cache-Control","no-store"); // I must use this to prevent response caching in HTTP 1.1 
response.setDateHeader ("Expires", 0); // for proxy 
response.setHeader("Pragma",""); 

 Expected Results: 
 FileReference should work even "Pragma: no-cache" is set on the server. 
  
 Workaround (if any): 
- force "Pragma:" to an empty string, use only HTTP1.1 headers 
- add the session in the url of FileReference like this: "/MyAction.do;jsessionid=F401B8249286E3BD7E8C7C0376B474D5" 

Note: 
When FileReference fail on "error #2038", the Server is never reach by the Flash player.