We are using Spring Boot version 2.6.6, trying to send a simple multipart/related request from postman and are getting DecodingException: Could not find end of headers Please help.

Here is the code: public Mono<ServerResponse> postV2JobApplication(ServerRequest request) { return request.body(BodyExtractors.toMultipartData()) .flatMap(parts -> { logger.info("Here"); return Mono.just(1); }) .then(ServerResponse.ok().build()); }

Here is the postman request: ` curl --location --request POST 'http://localhost:9763/iapply/partner/v2/3/job-application' \ --header 'Content-Type: multipart/related; boundary="JobApplicationBoundary"' \ --data-raw '--JobApplicationBoundary Content-Description: application Content-Type: application/json

{ "jobId": 1015 } --JobApplicationBoundary Content-Type: text/xml Content-Description: resume

Candidate --JobApplicationBoundary-- ' `

This is the trace: "org.springframework.core.codec.DecodingException: Could not find end of headers at org.springframework.http.codec.multipart.MultipartParser$HeadersState.onComplete(MultipartParser.java:457) at org.springframework.http.codec.multipart.MultipartParser.hookOnComplete(MultipartParser.java:124) at reactor.core.publisher.BaseSubscriber.onComplete(BaseSubscriber.java:197) at org.springframework.http.server.reactive.AbstractListenerReadPublisher$State.onAllDataRead(AbstractListenerReadPublisher.java:475) [..]

Comment From: fredo999

I believe the issue is with the request being sent without a CRLF sequence. Postman is sending only LF at the end of lines, which is causing the error. Is there any way around this problem?

Comment From: poutsma

I believe the issue is with the request being sent without a CRLF sequence. Postman is sending only LF at the end of lines, which is causing the error. Is there any way around this problem?

From Spring Framework's side, there is no way around the CRLF check, as that is specified in RFC 1521.

So the only way I can think of is to make sure postman sends proper multipart requests. Perhaps this comment can help you.