Replies: 1 comment
|
In some cases you have to read the body earlier than the accept functions. But reading the body before all other checks are complete means you risk wasting resources if a subsequent check fails. You also aren't supposed to know what content-type is used for the body at that point. And if you have to stream read the body, you pretty much have to do that in accept callbacks anyway. Typically Sometimes you do have to read the body earlier, so if you really have to do it, do it. If not, defer the reading until the accept callbacks. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I was thinking of handling all input validation (query strings, maybe certain header values, but also the request body) inside the
malformed_request/2cowboy_restcallback, but the documentation says that "the body should not be read at this point".Why is that? Is it just because
malformed_request/2is called beforevalid_entity_length/2? Would anything break if I read the body early?All reactions