Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Fix incomplete multipart problem #113

Merged
merged 1 commit into from
Jan 28, 2019
Merged

Fix incomplete multipart problem #113

merged 1 commit into from
Jan 28, 2019

Conversation

iptq
Copy link
Contributor

@iptq iptq commented Nov 20, 2018

Seems like hyper is reading until it sees \r\n, and since that's not being sent, I get

ERROR 2018-11-20T08:47:28Z: actix_web::pipeline: Error occurred during request handling, status: 500 Internal Server Error Multipart stream is incomplete

This just adds the \r\n to the end so hyper has no problem seeing it.

@abonander
Copy link
Owner

This actually appears to affect Actix, not Hyper. And really, I would consider this to be a correctness issue with Actix as RFC 2046 doesn't require a trailing CRLF (parts in square brackets are optional):

multipart-body := [preamble CRLF]
                  dash-boundary transport-padding CRLF
                  body-part *encapsulation
                  close-delimiter transport-padding
                  [CRLF epilogue]

It looks like Actix uses .readline() to read the boundary which is why it's failing to read the terminating boundary without a CRLF: https://github.com/actix/actix-web/blob/master/src/multipart.rs#L170

This change here isn't going to break anything, but it's not going to prevent Actix from having issues with other clients, either.

@@ -257,7 257,7 @@ impl<'a, W: Write> MultipartWriter<'a, W> {
}

// always write the closing boundary, even for empty bodies
write!(self.inner, "--{}--", self.boundary)?;
write!(self.inner, "--{}--\r\n", self.boundary)?;
Copy link
Owner

@abonander abonander Nov 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm prepared to merge this since Actix isn't moving quickly on the issue I opened. Can you add a comment here saying the CRLF is not specified for but some servers expect it?

@abonander abonander merged commit 9ce18d0 into abonander:master Jan 28, 2019
@abonander
Copy link
Owner

Published as 0.16.1.

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

Successfully merging this pull request may close these issues.

2 participants