IE11 receives truncated PDF for native display

Hello,

Just testing our app in IE11. Most things work well but one of the things it does is to display a PDF document in the browser using a StreamResource. IE puts up the question at the bottom of the window asking if I want to Open, Save or Cancel. I notice that if I Save then open the folder to look at the PDF file I see that the file is truncated either to 0 bytes or maybe half the size. Sometimes I get an error in the log:

org.apache.catalina.connector.ClientAbortException: java.io.IOException: There is no process to read data written to a pipe.
	at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:351)
	at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:776)
	at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:681)
	at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:386)
	at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:364)
	at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96)
	at com.vaadin.flow.server.StreamResource$Pipe.copy(StreamResource.java:95)
	at com.vaadin.flow.server.StreamResource$Pipe.accept(StreamResource.java:77)
	at com.vaadin.flow.server.communication.StreamResourceHandler.handleRequest(StreamResourceHandler.java:87)
	at com.vaadin.flow.server.communication.StreamRequestHandler.handleRequest(StreamRequestHandler.java:104)
	at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1545)
	at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:247)
	at com.vaadin.flow.spring.SpringServlet.service(SpringServlet.java:111)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	etc.

Any ideas (other than not bothering with IE11)?

Thanks, Mark.

I think I have solved (worked around) this now. In another part of our app we show an image and the user can choose to show a PDF version. This worked fine, so I guessed it was not that PDFs could not be displayed and suspected it was some kind of timing issue. My modified code waits for a second in a new thread then pushes the PDF to the browser for native display.

	//--------------------------------------------------------------------------
	private void showNative(final String name, final InputStream is) {
		log.info("Browser native display - {}", name);
		final UI ui = UI.getCurrent();
		log.info("UI is {}", ui);
		String userAgentString = ui.getSession().getBrowser().getBrowserApplication();
		if (userAgentString.toLowerCase().contains("trident/") || userAgentString.toLowerCase().contains("msie")) {
			log.info("IE 11 or 10- detected in {}", userAgentString);
			new Thread(() -> {
				log.info("About to sleep for 1 sec to give IE a moment to rejigalise");
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					log.info("Interrupted");
				}
				ui.accessLater(() -> {
					showNativeIFrame(name, is);
				}, null).run();
			}).start();
		}	// if - IE11 or IE10-
		else {
			showNativeIFrame(name, is);
		}
		log.info("Done showNative");
	}

	//--------------------------------------------------------------------------
	private void showNativeIFrame(final String name, final InputStream is) {
		log.info("About to add iframe");
		final IFrame iframe = new IFrame();
		final StreamResource resource = new StreamResource(name, () -> is);
		iframe.getElement().setAttribute("src", resource);
		mDocContainer.getElement().setAttribute(STYLE, OVERFLOW_HIDDEN); // to prevent scroll bars appearing
		iframe.setSizeFull();
		mDocContainer.add(iframe);
		log.info("Done add iframe");
	}

Thanks, Mark.