Frank Kobzik has posted comments on this change.

Change subject: engine: Fixes in non plugin console invocation
......................................................................


Patch Set 1: (6 inline comments)

....................................................
File 
backend/manager/modules/root/src/main/java/org/ovirt/engine/core/GetAttachmentServlet.java
Line 16:     private static final long serialVersionUID = 8496520437603585173L;
Line 17: 
Line 18:     @Override
Line 19:     protected void doPost(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException {
Line 20:         request.setCharacterEncoding("UTF-8");
All browsers I tried (IE8, FF 18, Chromium 23) sent requests as UTF-8 while 
servlet assumes POST parameters encoding to be iso-8859-1.
Line 21:         String contentType = request.getParameter("contenttype");
Line 22:         String fileName = request.getParameter("filename");
Line 23:         Boolean cache = 
Boolean.parseBoolean(request.getParameter("cache"));
Line 24:         String encodingType = request.getParameter("encodingtype");


Line 19:     protected void doPost(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException {
Line 20:         request.setCharacterEncoding("UTF-8");
Line 21:         String contentType = request.getParameter("contenttype");
Line 22:         String fileName = request.getParameter("filename");
Line 23:         Boolean cache = 
Boolean.parseBoolean(request.getParameter("cache"));
parseBoolean evaluates this as false, which is default.
Line 24:         String encodingType = request.getParameter("encodingtype");
Line 25:         String content = request.getParameter("content");
Line 26: 
Line 27:         if (contentType != null) {


Line 23:         Boolean cache = 
Boolean.parseBoolean(request.getParameter("cache"));
Line 24:         String encodingType = request.getParameter("encodingtype");
Line 25:         String content = request.getParameter("content");
Line 26: 
Line 27:         if (contentType != null) {
Done
Line 28:             response.setContentType(contentType);
Line 29:         }
Line 30: 
Line 31:         if (fileName == null) {


Line 27:         if (contentType != null) {
Line 28:             response.setContentType(contentType);
Line 29:         }
Line 30: 
Line 31:         if (fileName == null) {
this param will be removed.
Line 32:             fileName = "attachment";
Line 33:         }
Line 34:         response.setHeader("Content-Disposition", "attachment; 
filename*='UTF-8'" + 
URLEncoder.encode(StringEscapeUtils.unescapeHtml(fileName), "UTF-8"));
Line 35: 


Line 30: 
Line 31:         if (fileName == null) {
Line 32:             fileName = "attachment";
Line 33:         }
Line 34:         response.setHeader("Content-Disposition", "attachment; 
filename*='UTF-8'" + 
URLEncoder.encode(StringEscapeUtils.unescapeHtml(fileName), "UTF-8"));
The content-type header can be set via parameter. In our case it is 
application/x-virt-viewer.

I used the Content-Disposotion: attachment, because it's in the HTTP 
specification
http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html
and it indeed works in all browsers except IE (altough no error occurs - the 
filename is only ignored). All reasonable browsers derive suggested filename 
from this header. 

I tried to remove this header and it seems that Firefox derives the filename 
from the url (same as IE), so I think we can remove this header.
Line 35: 
Line 36:         if (!cache) {
Line 37:             response.setHeader("Cache-Control", "max-age=0, 
must-revalidate"); //disable caching HTTP/1.1
Line 38:             response.setHeader("Expires", "Sat, 26 Jul 1997 05:00:00 
GMT"); //disable caching HTTP/1.0


Line 41:         if (content == null) {
Line 42:             return;
Line 43:         }
Line 44: 
Line 45:         if ("binary".equals(encodingType)) {
Done
Line 46:             
response.getOutputStream().write(Base64.decodeBase64(content));
Line 47:         } else if ("plain".equals(encodingType)) {
Line 48:             content = StringEscapeUtils.unescapeHtml(content);
Line 49: 


--
To view, visit http://gerrit.ovirt.org/13332
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I7fe6fbf274a9ac215e8f6593cc000f778a431928
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Frank Kobzik <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Frank Kobzik <[email protected]>
Gerrit-Reviewer: Libor Spevak <[email protected]>
Gerrit-Reviewer: Tomas Jelinek <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to