Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StreamResource handling is broken in Spring applications #3244

Closed
Legioth opened this issue Jan 3, 2018 · 5 comments
Closed

StreamResource handling is broken in Spring applications #3244

Legioth opened this issue Jan 3, 2018 · 5 comments
Assignees
Milestone

Comments

@Legioth
Copy link
Member

Legioth commented Jan 3, 2018

A simple link for downloading a dynamically generated file does not work in the Spring skeleton starter, but the same code works as expected in the non-spring skeleton starter.

StreamResource resource = new StreamResource("filename", () -> new ByteArrayInputStream("Hello world".getBytes()));
Anchor download = new Anchor("", "Download configuration");
download.getElement().setAttribute("href", resource);

In the Spring case, the target URL seems to trigger the RouteNotFoundError handler instead of serving the StreamResource contents.

@Legioth
Copy link
Member Author

Legioth commented Jan 3, 2018

This seems to be caused by the way the servlet is mapped when using Spring.

Requests reaching StreamRequestHandler have the VAADIN/ part of the requested URL as getServletPath() whereas the logic expects the full URL to be in getPathInfo(). This is further complicated by the fact that getServletPath() is only available in VaadinServletRequest, but not in the generic VaadinRequest interface.

@Legioth
Copy link
Member Author

Legioth commented Jan 3, 2018

One idea for fixing this might be to introduce an additional method into VaadinRequest that gets the request URL relative to the context root, i.e. servletPath+ pathInfo. Logic that is always assumed to be mapped to the context root, e.g. anything related to the VAADIN/ namespace would then use this new method instead of the currently used getPathInfo().

@Legioth
Copy link
Member Author

Legioth commented Jan 9, 2018

The same issue probably also applies to e.g. Upload handling.

@heruan
Copy link
Member

heruan commented Jan 9, 2018

I confirm, same issue with Upload.

@denis-anisimov
Copy link
Contributor

Issue moved to vaadin/spring #273 via ZenHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants