Skip to content
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

Open
wants to merge 3 commits into
base: maint-25
Choose a base branch
from

Conversation

Whaileee
Copy link
Contributor

@Whaileee Whaileee commented Sep 6, 2024

No description provided.

@Whaileee Whaileee added the team:PS Assigned to OTP team PS label Sep 6, 2024
@Whaileee Whaileee self-assigned this Sep 6, 2024
@Whaileee Whaileee added the testing currently being tested, tag is used by OTP internal CI label Sep 6, 2024
@Whaileee
Copy link
Contributor Author

Whaileee commented Sep 6, 2024

This pr closes #8538

lib/inets/src/http_client/httpc.erl Outdated Show resolved Hide resolved
lib/inets/src/http_client/httpc_request.erl Outdated Show resolved Hide resolved
lib/inets/src/http_client/httpc_request.erl Outdated Show resolved Hide resolved
Comment on lines 886 to 895
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}}}} ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}}}} ->

Copy link
Contributor

github-actions bot commented Sep 6, 2024

CT Test Results

  2 files   21 suites   12m 17s ⏱️
334 tests 310 ✅ 23 💤 1 ❌
558 runs  519 ✅ 39 💤 0 ❌

For more details on these failures, see this check.

Results for commit abf2130.

♻️ 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

@Whaileee Whaileee force-pushed the whaileee/maint-25/inets/httpc_improvements branch from 0ea1b80 to abf2130 Compare September 9, 2024 09:30
@Whaileee Whaileee changed the base branch from maint-25 to maint September 10, 2024 13:21
@Whaileee Whaileee changed the base branch from maint to maint-25 September 10, 2024 13:22
@@ -379,6 +379,12 @@
ReplyInfo}</c>.</p>
</item>

<tag><c>alias()</c></tag>
Copy link
Contributor

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 ?

@@ -1144,6 +1163,7 @@ request_options([{Key, DefaultVal, Verify} | Defaults], Options, Acc) ->
BodyFormat :: string() | binary() | atom(),
SocketOpt :: term(),
Receiver :: pid()
Copy link
Contributor

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())?

cancel_request(RequestId),
unalias(ClientAlias),
receive
{http, {RequestId, {ok, saved_to_file}}} ->
Copy link
Contributor

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?

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Comment on lines +1089 to +1090
(Value) when is_reference(Value) ->
ok;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Comment on lines +885 to +900
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation (whole after block)

Comment on lines +1177 to +1178
Reference when is_reference(Reference) ->
ok;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

@u3s
Copy link
Contributor

u3s commented Sep 17, 2024

PR title could be adjusted to be more meaningful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

httpc:request full_result option does not work in async mode
3 participants