armeria icon indicating copy to clipboard operation
armeria copied to clipboard

Fix Multipart not to raise an exception when ending boundary only

Open minwoox opened this issue 3 years ago • 2 comments

Motivation: A Multipart can be terminated with the ending boundary without a body part. For example, the following request is totally valid:

POST /test.html HTTP/1.1
Host: example.org
Content-Type: multipart/form-data;boundary="boundary"

--boundary--

We must not raise an exception in that case.

Modifications:

  • Do not raise an exception when Multipart has the ending boundary only.
  • Propagate an exception in MultipartDecoder to the subscriber correctly.
  • Change to return false from StreamMessage.isEmpty() when the StreamMessage is created from a empty Multipart
    • Because it produces the ending boundary.

Result:

  • You no longer see a 500 response when an empty multipart request is sent.

minwoox avatar Sep 16 '22 07:09 minwoox

@minwoox Thank You for working on this :)

chungonn avatar Sep 16 '22 09:09 chungonn

Codecov Report

Base: 74.06% // Head: 74.11% // Increases project coverage by +0.04% :tada:

Coverage data is based on head (3d543b7) compared to base (1c4f2de). Patch coverage: 71.73% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4432      +/-   ##
============================================
+ Coverage     74.06%   74.11%   +0.04%     
- Complexity    18104    18121      +17     
============================================
  Files          1527     1527              
  Lines         67091    67133      +42     
  Branches       8478     8489      +11     
============================================
+ Hits          49692    49753      +61     
+ Misses        13346    13328      -18     
+ Partials       4053     4052       -1     
Impacted Files Coverage Δ
...m/linecorp/armeria/common/multipart/Multipart.java 92.59% <ø> (ø)
.../linecorp/armeria/common/multipart/MimeParser.java 86.38% <68.57%> (-2.82%) :arrow_down:
...orp/armeria/common/multipart/MultipartDecoder.java 91.33% <80.00%> (-1.10%) :arrow_down:
...orp/armeria/common/multipart/DefaultMultipart.java 86.81% <100.00%> (+5.49%) :arrow_up:
...a/internal/common/stream/DecodedStreamMessage.java 82.35% <0.00%> (-1.69%) :arrow_down:
.../linecorp/armeria/client/Http1ResponseDecoder.java 57.30% <0.00%> (-0.59%) :arrow_down:
...com/linecorp/armeria/server/HttpServerHandler.java 80.14% <0.00%> (-0.37%) :arrow_down:
...meria/spring/AbstractArmeriaAutoConfiguration.java 71.42% <0.00%> (ø)
...com/linecorp/armeria/client/RedirectingClient.java 73.21% <0.00%> (+0.44%) :arrow_up:
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Sep 16 '22 09:09 codecov[bot]

Thanks, reviewers. 😉

minwoox avatar Sep 30 '22 01:09 minwoox