aws-beam / aws-codegen

Code generator for AWS clients in Erlang and Elixir.
Other
53 stars 49 forks source link

Support responses with partial content(using the Range request header) where HTTP code 206 is returned. #81

Closed danfilip closed 2 years ago

danfilip commented 2 years ago

When making partial requests using the Range header, to get a chunk of the file, the response HTTP code is 206, but it's not handled as a success code.

onno-vos-dev commented 2 years ago

Diff generated towards aws_s3 which is the main problematic file as per the PR to aws-erlang

Not a regular maintainer of this repo but LGTM

diff --git a/src/aws_s3.erl b/src/aws_s3.erl
index d722f8d..52c2b88 100644
--- a/src/aws_s3.erl
+++ b/src/aws_s3.erl
@@ -7446,6 +7446,7 @@ handle_response({ok, StatusCode, ResponseHeaders}, SuccessStatusCode, _DecodeBod
   when StatusCode =:= 200;
        StatusCode =:= 202;
        StatusCode =:= 204;
+       StatusCode =:= 206;
        StatusCode =:= SuccessStatusCode ->
     {ok, {StatusCode, ResponseHeaders}};
 handle_response({ok, StatusCode, ResponseHeaders}, _, _DecodeBody) ->
@@ -7454,6 +7455,7 @@ handle_response({ok, StatusCode, ResponseHeaders, Client}, SuccessStatusCode, De
   when StatusCode =:= 200;
        StatusCode =:= 202;
        StatusCode =:= 204;
+       StatusCode =:= 206;
        StatusCode =:= SuccessStatusCode ->
     case hackney:body(Client) of
         {ok, <<>>} when StatusCode =:= 200;