-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle get_object with range #21
Conversation
Thank you for your contribution. I've merge this request with |
In addition, I found Leo Gateway could not pass the unit test as below:
|
Bug fix for End < 0 |
@windkit I've checked your request, again and then confirmed the test case. There is no issue. Thanks. |
get_range_object_1(Req, Bucket, Key, Range, undefined, Socket, Transport) | ||
end, | ||
Req), | ||
?reply_ok(Header, Req2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@windkit @yosukehara
Sorry for the late reply to this pull request.
To comply with HTTP spec,
We need to respond HTTP_ST_PARTIAL_CONTENT(206) as a status code so reply_ok can't use.
reopen |
30e3d0b
to
e7e7c38
Compare
I have pushed the commits addressing @mocchira comments. BTW, I am not sure why the CI build is failing... as I can't reproduce it on my machine |
@windkit almost LGTM.
This error might depend on Erlang version. |
{error, unavailable} -> | ||
?reply_service_unavailable_error([?SERVER_HEADER], Key, <<>>, Req); | ||
_ -> | ||
?reply_not_found([?SERVER_HEADER], Key, <<>>, Req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to handle errors of the below clauses
- {error, ?ERR_TYPE_INTERNAL_ERROR}
- {error, timeout}
fun(Socket, Transport) -> | ||
get_range_object_1(Req, Bucket, Key, Range, undefined, Socket, Transport) | ||
end, | ||
Req), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@windkit I found out why CI failed.
You need to use set_resp_body_fun's another version.
https://github.com/ninenines/cowboy/blob/1.0.0/src/cowboy_req.erl#L776
Try to pass the content length you calculated as the first argument.
Since R16B03-1 coudn't understand transfer-encoding: identify, this error have occured on CI.
https://github.com/erlang/otp/blob/OTP_R16B03-1/lib/inets/src/http_client/httpc_handler.erl#L1122
The latest one can understand this header.
https://github.com/erlang/otp/blob/OTP-17.5.6/lib/inets/src/http_client/httpc_handler.erl#L1130
@mocchira Thanks for helping to sort out the cause. |
@windkit YW and GJ!
Yes. |
@yosukehara |
And setting both actually breaks other clients such as boto (Python)....... |
I've merged your code with the branch of |
Short Summary of setting Setting both, breaks Setting Setting |
@windkit Thank you for the Good summary. So Applying the patch which replace <<"content-length">> at this line https://github.com/ninenines/cowboy/blob/1.0.0/src/cowboy_req.erl#L869 with <<"Content-Length">> will solve all issues? |
@mocchira The fix seems working, the issue I encountered after applying the patch was related to |
Tested with the simple "Content-Length" Hack, works fine |
LGTM. |
I've added other fixed code: leo-project/cowboy@22a4dcf |
I've merged your code with
|
About issue leo-project/leofs#376
Instead of using transfer-encoding:chunked, respond with HTTP 200 and resp_body_func
(Note: aws-java-jdk is case-sensitive to HTTP Headers... cowboy internally uses lower case which does not match)
Code is not polished at the moment, I have only tested with a short Java program
Also Unit test is broken at the moment because it checks against transfer-encoding:chunked