IE11 receives truncated PDF for native display


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: There is no process to read data written to a pipe.
	at org.apache.catalina.connector.OutputBuffer.realWriteBytes(
	at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(
	at org.apache.catalina.connector.OutputBuffer.append(
	at org.apache.catalina.connector.OutputBuffer.writeBytes(
	at org.apache.catalina.connector.OutputBuffer.write(
	at org.apache.catalina.connector.CoyoteOutputStream.write(
	at com.vaadin.flow.server.StreamResource$Pipe.copy(
	at com.vaadin.flow.server.StreamResource$Pipe.accept(
	at com.vaadin.flow.server.communication.StreamResourceHandler.handleRequest(
	at com.vaadin.flow.server.communication.StreamRequestHandler.handleRequest(
	at com.vaadin.flow.server.VaadinService.handleRequest(
	at com.vaadin.flow.server.VaadinServlet.service(
	at com.vaadin.flow.spring.SpringServlet.service(
	at javax.servlet.http.HttpServlet.service(

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

	private void showNativeIFrame(final String name, final InputStream is) {"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
		mDocContainer.add(iframe);"Done add iframe");

Thanks, Mark.