On Tue, Mar 26, 2013 at 8:42 PM, Howard W. Smith, Jr. < smithh032...@gmail.com> wrote:
> Chris, > > On Tue, Mar 26, 2013 at 4:00 PM, Christopher Schultz < > ch...@christopherschultz.net> wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA256 >> >> Howard, >> >> On 3/25/13 11:54 AM, Howard W. Smith, Jr. wrote: >> > Test and results: >> > >> > clicked Download button, PDF downloaded to Google Nexus 7 (Google >> > Chrome browser, of course), showed up in notifications, instead of >> > PDF Viewer app, I selected to open the PDF document in Adobe >> > Acrobat (app that was downloaded from Google Play). >> > >> > ---view--- <h:commandLink value="View" target="_blank" >> > >> > actionListener="#{pf_ordersController.refreshContractsToDownload()}"> >> > >> > >> <p:fileDownload value="#{contractToDownload.file}" >> > contentDisposition="inline"/> </h:commandLink> >> > >> > Test and results: >> > >> > clicked View button, I saw another web page tab open rather quickly >> > in the Google Chrome browser on Google Nexus 7, and then the new >> > tab closed immediately, and then I saw the 'Starting download' >> > toast (at bottom of Google Nexus 7), but I didn't see the file in >> > notifications or downloads, and I didn't see any exceptions in my >> > TomEE/tomcat7 logs. >> > >> > With that said, maybe I just duplicated this issue/exception that >> > you have been experiencing. If I'm not mistaking, PrimeFaces is >> > using the servlet solution for file downloads. >> >> What servlet ultimately returns the bytes to the client? If it's >> Tomcat's DefaultServlet, then - following my line of thought elsewhere >> in this thread - Range requests are likely being respected. >> > > That's a good question. I'm unable to answer that at the moment. Per your > question, I'm doing some reading on this now; since this is a JSF web > application / project, I'm referring to some BalusC blogs/answers on > stackoverflow. According to this one response of his[1], I assume that I am > using Tomcat default servlet, but I could be mistaking here. Also, please > note, my container is TomEE 1.6.0 SNAPSHOT (which is Tomcat 7.0.37, > currently). > > This is the first time I have heard about 'range request', but since you > mentioned it, I am seeing it mentioned elsewhere. > > > [1] http://stackoverflow.com/a/3428207/933054 > > I read your other response to the OP about range request and tomcat respecting it. I am doing some research and I found the following: BalusC says, in an older/2009 blog[1], yes obviously it is old, because back then, he said, You could leverage the task to a default servlet of the webcontainer/appserver you're using, but most of them doesn't implement all of the performance enhancements, so does for example Tomcat's DefaultServlet<http://tomcat.apache.org/tomcat-6.0-doc/default-servlet.html> *not* support the Expiresheader. but per what you said, Chris, he also mentioned the following in that blog, Resume downloads<http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html#ResumeDownloads> To enable download resumes, the server have to send at least the Accept-Ranges<http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5> , ETag <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19> and Last-Modified<http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29> response headers to the client along with the file. The Accept-Ranges response header with the value "bytes" informs the client that the server supports byte-range requests. With this the client could request for a specific byte range using the Range<http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35> request header. One line from the code below, externalContext.setResponseHeader("Content-Disposition", contentDispositionValue + ";filename=\"" + content.getName() + "\""); shows that the server is not sending a response header containing range request. Am I correct? The code below: public void processAction(ActionEvent actionEvent) throws AbortProcessingException { FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); StreamedContent content = (StreamedContent) value.getValue(elContext); if(content == null) { return; } ExternalContext externalContext = facesContext.getExternalContext(); String contentDispositionValue = contentDisposition != null ? (String) contentDisposition.getValue(elContext) : "attachment"; try { externalContext.setResponseContentType(content.getContentType()); externalContext.setResponseHeader("Content-Disposition", contentDispositionValue + ";filename=\"" + content.getName() + "\""); externalContext.addResponseCookie(Constants.DOWNLOAD_COOKIE, "true", new HashMap<String, Object>()); byte[] buffer = new byte[2048]; int length; InputStream inputStream = content.getStream(); OutputStream outputStream = externalContext.getResponseOutputStream(); while ((length = (inputStream.read(buffer))) != -1) { outputStream.write(buffer, 0, length); } externalContext.setResponseStatus(200); externalContext.responseFlushBuffer(); inputStream.close(); facesContext.responseComplete(); } catch(IOException e) { throw new FacesException(e); } } [1] http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html > >> - -chris >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG/MacGPG2 v2.0.17 (Darwin) >> Comment: GPGTools - http://gpgtools.org >> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ >> >> iQIcBAEBCAAGBQJRUf5VAAoJEBzwKT+lPKRYd9EQAJIKMPy+h/ULF2pCfjQ7lKpD >> IlPc5k35YwHxfNu1l1HKuP2Fn/RdynxmtHdE5bcNfgvaEMN8ogRTgcAf0obROwDt >> xKHPLcX9D44+wc0tB3YWTrbXio8RnVsQDAChjrYUapANlTgclQWidNR2lqnHRtKZ >> j5DDqGQ9Rh9mQsvLU4/vtWXwm+MBwlluI0KfTnVVFNHH8hbtHi3bkUBrrUr5CBok >> afjU1URh7NKkgtVLfAzI9mWvsdlVDjdb6W/Hz2+bbcZjM13o833+h8TbxRrNbfyX >> DSRv75WjKTIaBwnEdNUG2ScqfudCdJZXwOz4UdaBNClzE0wLx2Jc0Tdd4cpjaXec >> mOXYlbUzZf2hbHOIltKP6BmzhIx83g8c2971yKTPI1b19nPae+QTSSeJJEDBchVA >> v0nNQWIZ1lNSS0X60FPIshOlZvQokOHYV1muYvSZjzu07PlT7yGwbhvtMXKncIDd >> 1TKIXAhCvF9kpBw2JAkx8cDaBfW1o5IXcJA85IXS+y2lvIzc7tNOetDCj7C3PHAk >> jEy6FPqV475X1cOXgLkLX5WRAJEuyZ3TuOpFDYsOJo39zqmzw5BPwLCL5rfCW+r5 >> 5GZyXjSurGqL8Sw/Jy4HpUGSWEBqOXqtctG9QpqzSdOv5uMz2uvqcoO49ADdUQTF >> rQHGMaf8KJl83fykc8np >> =d8sp >> -----END PGP SIGNATURE----- >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> >