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

Fail to process request with sub boundaries #2601

Open
radudeliu opened this issue Feb 4, 2024 · 1 comment
Open

Fail to process request with sub boundaries #2601

radudeliu opened this issue Feb 4, 2024 · 1 comment
Labels

Comments

@radudeliu
Copy link

Proposal

Hello,

I encountered two issues when using wiremock to test a request with sub boundaries:

  1. Wiremock is failing to parse a WebClient request with sub boundaries.
  2. If I configure WebClient to use the same size for the main boundary and for the sub boundary then the request is parsed by wiremock, but just the first part is identified, the rest are omitted.

Please let me know if more details is needed.

Thank you,
Radu

Reproduction steps

I attached a sample app with two test: wiremock_issues.zip

  1. callApi - it is demonstrate the first issue, fails to parse the request.
  2. callApi_whenSameSizeBoundary - it is demonstrate the second issue, fails to parse all the parts.

References

No response

@radudeliu radudeliu added the bug label Feb 4, 2024
@radudeliu radudeliu changed the title Fail to process request with sub boundaris Fail to process request with sub boundaries Feb 4, 2024
@leeturner
Copy link
Contributor

Hi @radudeliu Many thanks for taking the time to submit the issue and provide an example app demonstrating the problem. It was really useful 👍

In the example app you provided it looks like you are setting the MediaType to MULTIPART_MIXED.

partBuilder.part("part2", subPartBuilder.build(), MULTIPART_MIXED);

Was there a specific reason for this? If we omit the setting of the MediaType in this call, we get a multipart/form-data content type:

Content-Disposition: form-data; name="part2"
Content-Type: multipart/form-data;boundary=3DpujgWMzjn2RlaeXaOORgIjWQlsGq-zQg8jGkmG

This gives us a callClient method that looks like this:

    private Mono<String> callClient(WebClient webClient) {
        final var subPartBuilder = new MultipartBodyBuilder();
        subPartBuilder.part("part11", "part11_content").contentType(TEXT_PLAIN);
        subPartBuilder.part("part12", "part12_content").contentType(TEXT_PLAIN);

        final var partBuilder = new MultipartBodyBuilder();
        partBuilder.part("part1", "part1_content").contentType(TEXT_PLAIN);
        partBuilder.part("part2", subPartBuilder.build());

        return webClient
                .post()
                .contentType(MULTIPART_RELATED)
                .bodyValue(partBuilder.build())
                .retrieve()
                .bodyToMono(String.class);
    }

Using this all your tests pass. Would be interested to hear your thoughts

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

No branches or pull requests

2 participants