-
Notifications
You must be signed in to change notification settings - Fork 211
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
Dancer 1.3200 breaks request->body for form POST #1140
Comments
|
Bugger. Looking in to this one today. It's weird, as the PR included tests which ensure that response->body works as it should. |
|
Right - if you're POSTing raw content ( This seems reasonable - there should be no need to get the raw request body in that case, it should be of no use - but /is/ a change in behaviour from how things worked before this. I suspect an upstream patch to make HTTP::Body write the body content to a file in these cases would be rejected since in normal usage that's not useful. So, if we need to let request->body return raw content for url-encoded POSTs, then we may have to handle it ourselves - stashing it away into the request object as we parse the incoming request, and having request->body look for that first and return it if it was there, and if not, read and return the filehandle in |
|
Ah - but we won't know the type of request until we've passed enough data to I'm starting to think we should document this change of behaviour clearly and leave it be - I can't see it biting many people, and the new behaviour doesn't seem unreasonable. |
|
Well, one of my work apps was relying on this in a very core level, and everything has started crashing and misbehaving due to this change. Luckily we've caught in dev and pin to the old version now, but we can't upgrade it until either this gets fixed in Dancer or we add a workaround to it. It's useless when one method returns something in some occasion and nothing in others - that can't be reliably used at all. I'm sympathetic because it's due to an odd interface that HTTP::Body gives to you. Plack::Request buffers the body using Stream::Buffer on its own, and make a copy of filehandle so that the users can get it: https://metacpan.org/source/MIYAGAWA/Plack-1.0037/lib/Plack/Request.pm |
|
Plack::Request doesn't suffer from this kind of thing, so I'd say as long as you use them, it's fine :) |
|
Oh goodie. :) |
|
Sorry this has stalled for so long - I hope to have a workaround written up this weekend which will store the body of requests if the HTTP::Body object hasn't stored it for us, but I need to work out a clean way to go about it. Perhaps even better would be to discuss with the author/maintainer of HTTP::Body whether a patch to HTTP::Body to always make the body content available via the body accessor would be accepted, though. HTTP::Body's doco helpfully documents the body accessor as "accessor for the body" but doesn't mention that it'll give you a filehandle, or that it'll only work at all for certain types of HTTP bodies - so it may be better for it to be fixed there. |
|
In theory, yes. In reality, HTTP::Body has been semi-abandoned for a long time and there's little hope you can get it fixed there. In Plack we've recently switched to a custom HTTP parser tailored to handle PSGI environment. plack/Plack#538 |
|
Still looking at this one. I'd like to replace the use of HTTP::Body with the parser you're using in Plack, but I think it'd be an awful lot of work. Other options are to try hard to get a fix into HTTP::Body, or ship a modified version of HTTP::Body with Dancer, or implement some workaround in Dancer::Request which stores the request body if HTTP::Body is not going to do so - but I'm not sure if I can reliably detect whether it will before the fact - if not, it'd do away with the RAM usage savings from file uploads which the change which caused this problem was intended to provide. |
|
I have raised a ticket against HTTP::Body with a patch which makes the UrlEncoded parser still store the raw request body, just like the other parsers - I'd love to see this be accepted and a new HTTP::Body release go out with it. If that doesn't happen, though, then I'll need to consider whether we move away from HTTP::Body, ship a modified version of it with Dancer, or try to implement some hacky patch (although having looked in to this option first, it looks like that will be tricky...) |
Bundling a modified version of HTTP::Body. See #1140 for reasons behind this decision.
|
Don't worry, as soon as bigpresh talks to me he can have commit access and co-maint. HTTP::Body is semi-maintained because people keep not even trying to help maintain it; I can provide people with access as required. |
|
As per comment on other issue, if you are happy to give me a commit bit & co-maint, I'll happily help maintain it. |
|
I've been working on implementing the fix in HTTP::Body now mst has kindly set me up with access. Most of the way there with something that will work. The sticking point I'm working on is how it should work for multipart requests (e.g. file uploads) - the least surprising behaviour would be combining all the parts, leaving the boundaries in place etc - but that's unlikely to be of much use in most cases, and also difficult to implement without keeping the contents of all parts in a scalar, or writing the first part (URL-encoded form upload, usually) to disk along with the file parts, both of which are rather unacceptable. At this point I'm tempted to have it warn and return if body is called for a multipart request, or just have it return the first part only - but both of them would be somewhat surprising, if you expect |
#1134 has broken Dancer's
request->bodyfor form-based POST requests. The body method now returns nothing for such requests.Here's a failing test:
and its output:
The text was updated successfully, but these errors were encountered: