jgauffin / Griffin.Framework

Application framework for Business Applications
http://griffinframework.net
168 stars 63 forks source link

MessageDecoder deserialize only POST request #3

Closed crisim closed 10 years ago

crisim commented 10 years ago

MessageDecoder should deserialize only POST request and fixed error in CompositeSerializer

jgauffin commented 10 years ago

Bodies are allowed in all requests but HEAD according to the HTTP specification (RFC2616)

crisim commented 10 years ago

the RFC2616 states that responses to HEAD requests MUST NOT return an entity body. You've got a point not accepting the pull for another reason, we don't need to enforce the deserialization of the body in the CompositeSerializer if the content type of the request doesn't match "multipart/form-data" or "application/x-www-form-urlencoded", maybe a property or a constructor argument?

jgauffin commented 10 years ago

That's what I said. "all but HEAD". So you can't just parse bodies for POST as you did in your pull request..

Regarding the decoder, the problem is rather

if (formAndFiles != null)
                    {
                        request.Form = formAndFiles.Form;
                        request.Files = formAndFiles.Files;
                    }
                    else
                        throw new HttpException(500, "Unknown decoder result: " + result);

in HttpMessageDecoder.cs.

that should instead be else if (result != null). Because as you said, null should be OK. The check is there to make sure that no deserializer thinks that it works but do not (As it returned something that the HttpMessageDecoder can't handle).

jgauffin commented 10 years ago

So if you fix those two things I would gladly accept a new pull request.