Skip to content

Commit

Permalink
Fix s3tests.functional.test_s3:test_object_copy_to_itself
Browse files Browse the repository at this point in the history
  • Loading branch information
mocchira committed Jul 8, 2015
1 parent 37c677f commit fd5c49f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions include/leo_http.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
%% error codes used in a error response
-define(XML_ERROR_CODE_EntityTooLarge, "EntityTooLarge").
-define(XML_ERROR_CODE_InvalidArgument, "InvalidArgument").
-define(XML_ERROR_CODE_InvalidRequest, "InvalidRequest").
-define(XML_ERROR_CODE_AccessDenied, "AccessDenied").
-define(XML_ERROR_CODE_NoSuchKey, "NoSuchKey").
-define(XML_ERROR_CODE_InvalidRange, "InvalidRange").
Expand All @@ -145,6 +146,7 @@
%% error messages used in a error response
-define(XML_ERROR_MSG_EntityTooLarge, "Your proposed upload exceeds the maximum allowed object size.").
-define(XML_ERROR_MSG_InvalidArgument, "Invalid Argument").
-define(XML_ERROR_MSG_InvalidRequest, "SOAP requests must be made over an HTTPS connection.").
-define(XML_ERROR_MSG_AccessDenied, "Access Denied").
-define(XML_ERROR_MSG_NoSuchKey, "The specified key does not exist.").
-define(XML_ERROR_MSG_InvalidRange, "The requested range cannot be satisfied.").
Expand Down
34 changes: 20 additions & 14 deletions src/leo_gateway_s3_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,26 @@ put_object(Directive, Req, Key, #req_params{handler = ?PROTO_HANDLER_S3} = Param
_ ->
CS
end,

case leo_gateway_rpc_handler:get(CS2) of
{ok, #?METADATA{cnumber = 0} = Meta, RespObject} ->
put_object_1(Directive, Req, Key, Meta, RespObject, Params);
{ok, #?METADATA{cnumber = _TotalChunkedObjs} = Meta, _RespObject} ->
put_large_object_1(Directive, Req, Key, Meta, Params);
{error, not_found} ->
?reply_not_found([?SERVER_HEADER], Key, <<>>, Req);
{error, unavailable} ->
?reply_service_unavailable_error([?SERVER_HEADER], Key, <<>>, Req);
{error, ?ERR_TYPE_INTERNAL_ERROR} ->
?reply_internal_error([?SERVER_HEADER], Key, <<>>, Req);
{error, timeout} ->
?reply_timeout([?SERVER_HEADER], Key, <<>>, Req)
case Key =:= CS2 of
true ->
% 400
?reply_bad_request([?SERVER_HEADER], ?XML_ERROR_CODE_InvalidRequest,
?XML_ERROR_MSG_InvalidRequest, Key, <<>>, Req);
false ->
case leo_gateway_rpc_handler:get(CS2) of
{ok, #?METADATA{cnumber = 0} = Meta, RespObject} ->
put_object_1(Directive, Req, Key, Meta, RespObject, Params);
{ok, #?METADATA{cnumber = _TotalChunkedObjs} = Meta, _RespObject} ->
put_large_object_1(Directive, Req, Key, Meta, Params);
{error, not_found} ->
?reply_not_found([?SERVER_HEADER], Key, <<>>, Req);
{error, unavailable} ->
?reply_service_unavailable_error([?SERVER_HEADER], Key, <<>>, Req);
{error, ?ERR_TYPE_INTERNAL_ERROR} ->
?reply_internal_error([?SERVER_HEADER], Key, <<>>, Req);
{error, timeout} ->
?reply_timeout([?SERVER_HEADER], Key, <<>>, Req)
end
end.

%% @doc POST/PUT operation on Objects. COPY
Expand Down

0 comments on commit fd5c49f

Please sign in to comment.