hackney icon indicating copy to clipboard operation
hackney copied to clipboard

Feature Request: body/2 error when body exceeds MaxLength

Open pedep opened this issue 7 years ago • 3 comments

Currently, when you process a request that exceeds MaxLength, the incomplete result silently returns. This is not always that helpful, because an impartial result might not be parseable. Since no error gets returned by hackney, its not possible to distinguish between malformed responses and excessively large responses that have been cropped.

I am using hackney through HTTPoison, and would like to support this behaviour. Would this use-case fit hackney, or am i better off submitting a PR downstream in HTTPoison?

pedep avatar Sep 17 '18 11:09 pedep

should be in hackney. I guess returning {error, {partial_body, Body}} or similar would do the trick

benoitc avatar Sep 28 '18 13:09 benoitc

Alright! :) I toyed around with the idea downstream, and it seems to work fine (https://github.com/edgurgel/httpoison/pull/356)

Are you okay with changing the default behavior, or would it be better to provide a new function/an option?

I wouldn't mind writing a quick PR, but I'm not quite confident enough in my Erlang to guarantee anything good

pedep avatar Sep 28 '18 14:09 pedep

i guess it should be an option for the current release version

On Friday, September 28, 2018, pedep [email protected] wrote:

Alright! :) I mucked around with the idea downstream, and it seems to work fine ( edgurgel/httpoison#356 https://github.com/edgurgel/httpoison/pull/356)

Are you okay with changing the default behavior, or would it be better to provide a new function/an option?

I wouldn't mind writing a quick PR, but I'm not quite confident enough in my Erlang to guarantee anything good

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/benoitc/hackney/issues/533#issuecomment-425448014, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA4orGzWMQDCCWI52CuSLt5fWi0CrnOks5ufi3ggaJpZM4WrtQd .

-- Sent from my Mobile

benoitc avatar Sep 28 '18 14:09 benoitc