Hacky Support for /as4 endpoint due to platform dependent line endings #249
Replies: 2 comments 4 replies
-
@piotr-dajlido well, phase4 is designed independent of any specific application server, Spring framework and the like. Therefore, you need to make sure, that you don't add any specific application server filtering on that servlet - it contains it all. My assumption is, that you added the
|
Beta Was this translation helpful? Give feedback.
-
@phax could you please explain to me what is @Slf4j
@Configuration
public class AS4SpringServletConfig {
public AS4SpringServletConfig(ServletContext servletContext) {
if (!WebScopeManager.isGlobalScopePresent()) {
WebScopeManager.onGlobalBegin(servletContext);
_initGlobalSettings(servletContext);
_initAS4();
}
} Tested twice, with same request payload @phax I'am extreamly close to achive integration with Spring Web. I have already managed to get This is how I picture use of Phase4 Which acctualy makes me think that |
Beta Was this translation helpful? Give feedback.
-
Problem Description
There are some issues with sending direct requests to the default /as4 endpoint. Requests with a
Content-Type: multipart/related
are parsed using a copy of the org.apache.tomcat.util.http.fileupload.MultipartStream class, which is utilized by AS4IncomingHandler.class. TheMultipartStream
class adheres toRFC 1867
, which specifies that multipart part boundaries are delimited by doubleCRLF
line endings. This causes aStreamClosedUnexpectedly
error when the payload is sent withLF
(Linux) orCR
(Mac) line endings.Additionally, there is no guarantee that some
RequestFilters
might not be rewriting the request payload'sInputStream
to convertCRLF
toLF
, which depends on the framework being used. In my case, disabling security and turning off all defaultSpring
filters did not resolve the issue.Hacky Solution
To address this issue, I created the following class:
This class wraps the InputStream used in AS4IncomingHandler during multipart/related deserialization (around line 213 of AS4IncomingHandler.class):
Moreover requests from Postman (Windows) work fine, problem starts when triggered from for e.g. Linux container
Beta Was this translation helpful? Give feedback.
All reactions