-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[OTP-19158][OTP-19221] whaileee/maint-25/inets/httpc_improvements #8788
[OTP-19158][OTP-19221] whaileee/maint-25/inets/httpc_improvements #8788
Conversation
This pr closes #8538 |
lib/inets/src/http_client/httpc.erl
Outdated
unalias(ClientAlias), | ||
receive | ||
{http, {RequestId, {ok, saved_to_file}}} -> | ||
{ok, saved_to_file}; | ||
{http, {RequestId, {error, Reason}}} -> | ||
{error, Reason}; | ||
{http, {RequestId, {ok, {StatusLine,Headers,BinBody}}}} -> | ||
Body = maybe_format_body(BinBody, Options), | ||
{ok, {StatusLine, Headers, Body}}; | ||
{http, {RequestId, {ok, {StatusCode,BinBody}}}} -> |
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.
unalias(ClientAlias), | |
receive | |
{http, {RequestId, {ok, saved_to_file}}} -> | |
{ok, saved_to_file}; | |
{http, {RequestId, {error, Reason}}} -> | |
{error, Reason}; | |
{http, {RequestId, {ok, {StatusLine,Headers,BinBody}}}} -> | |
Body = maybe_format_body(BinBody, Options), | |
{ok, {StatusLine, Headers, Body}}; | |
{http, {RequestId, {ok, {StatusCode,BinBody}}}} -> | |
true = unalias(ClientAlias), | |
receive | |
{http, {RequestId, {ok, saved_to_file}}} -> | |
{ok, saved_to_file}; | |
{http, {RequestId, {error, Reason}}} -> | |
{error, Reason}; | |
{http, {RequestId, {ok, {StatusLine, Headers, BinBody}}}} -> | |
Body = maybe_format_body(BinBody, Options), | |
{ok, {StatusLine, Headers, Body}}; | |
{http, {RequestId, {ok, {StatusCode, BinBody}}}} -> |
CT Test Results 2 files 21 suites 11m 29s ⏱️ For more details on these failures, see this check. Results for commit fb19f1c. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
0ea1b80
to
abf2130
Compare
lib/inets/doc/src/httpc.xml
Outdated
@@ -379,6 +379,12 @@ | |||
ReplyInfo}</c>.</p> | |||
</item> | |||
|
|||
<tag><c>alias()</c></tag> |
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.
is alias() used in parallel to pid() now? or should alias replace pid?
if both are used, maye we should give some hint which one is used when ... or why and when alias is better ?
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.
I don't think alias should replace pid, as they are two separate datatypes, even if they serve a similar purpose. I believe that by looking up, or knowing what exactly alias is, end-user will be able to judge whether to use pid or alias.
@@ -1144,6 +1163,7 @@ request_options([{Key, DefaultVal, Verify} | Defaults], Options, Acc) -> | |||
BodyFormat :: string() | binary() | atom(), | |||
SocketOpt :: term(), | |||
Receiver :: pid() |
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.
Receiver type is repeated several times in this module. Should it always include alias type (i.e. reference())?
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.
This is the new default for sync requests. Users have to specify the receiver when using {sync, false}.
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.
You lost me, the alias should used for the sync request to ensure that you can time it out without the user process receiving a message that it does not expect. The alias should not be something that the user of the inets API is aware of.
lib/inets/src/http_client/httpc.erl
Outdated
cancel_request(RequestId), | ||
unalias(ClientAlias), | ||
receive | ||
{http, {RequestId, {ok, saved_to_file}}} -> |
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.
write a code comment explaining why 2nd almost the same receive block is repeated in after Timeout
?
is it supposed to handle some race condition? did you observe it in test runs?
why not give up and return error instantly?
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.
This is in case the message comes in after Timeout but before unalias
, It ensures that the message queue doesn't contain junk that is unreachable.
lib/inets/src/http_client/httpc.erl
Outdated
case httpc_manager:request(Request, profile_name(Profile)) of | ||
{ok, RequestId} -> | ||
handle_answer(RequestId, Sync, Options); | ||
handle_answer(RequestId, Receiver, Sync, Options, | ||
element(#http_options.timeout, HTTPOptions)); |
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.
indentation
lib/inets/src/http_client/httpc.erl
Outdated
(Value) when is_reference(Value) -> | ||
ok; |
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.
indentation
lib/inets/src/http_client/httpc.erl
Outdated
cancel_request(RequestId), | ||
unalias(ClientAlias), | ||
receive | ||
{http, {RequestId, {ok, saved_to_file}}} -> | ||
{ok, saved_to_file}; | ||
{http, {RequestId, {error, Reason}}} -> | ||
{error, Reason}; | ||
{http, {RequestId, {ok, {StatusLine, Headers, BinBody}}}} -> | ||
Body = maybe_format_body(BinBody, Options), | ||
{ok, {StatusLine, Headers, Body}}; | ||
{http, {RequestId, {ok, {StatusCode, BinBody}}}} -> | ||
Body = maybe_format_body(BinBody, Options), | ||
{ok, {StatusCode, Body}} | ||
after 0 -> | ||
{error, timeout} | ||
end |
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.
indentation (whole after block)
lib/inets/src/http_client/httpc.erl
Outdated
Reference when is_reference(Reference) -> | ||
ok; |
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.
indentation
PR title could be adjusted to be more meaningful |
fd5fcc0
to
6f4c5e0
Compare
6f4c5e0
to
6c07478
Compare
4aaf71d
to
fb19f1c
Compare
No description provided.