extend/cowboy — pull request #663 by nlebedenco (2014-01-23 23:52:35+00:00)
Title: Add cowboy_req:fetch_body/1,2 to retrieve the request body regardless of its transfer-encoding up to a maximum length of actual data (not a segment size)

After #660 and thinking more about how transfer-encodings work and how content-encodings may affect data, it seems counter-intuitive to rely directly on stream_body/1,2 and how MaxSegmentSize works. Generally a server developer is more interested in the actual data sent by the client (in other words, after decode takes place) and would want to validate this data (think of cowboy_rest callback valid_entity_length/2, for example). For this purpose, a more natural way of retrieving body data wthout relying of a known conten-length would be (regardless of transfer-encoding and content-encoding) get decoded data up to a safeguard (MaxDataLength). This is somewhat related to #453 but an error is returned in case there's more data then MaxDataLength and an updated Req is returned even in case of errors as intermediate stream_body/2,3 calls may have changed it.