erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.3k stars 2.94k forks source link

httpc:request full_result option does not work in async mode #8538

Open Xavier59 opened 3 months ago

Xavier59 commented 3 months ago

Describe the bug As per erlang documentation on httpc:request options:

full_result - Defines if a "full result" is to be returned to the caller (that is, the body, the headers, and the entire status line) or not (the body and the status code).

Default is true.

It it not specified that it does not apply if the request is async. The logical conclusion is that it applies to both.

To Reproduce Steps to reproduce the behavior.

inets:start(),
httpc:request(get, {"http://example.com/", []}, [], [{full_result, false}]),
httpc:request(get, {"http://example.com/", []}, [], [{full_result, false}, {sync, false}, {receiver, fun(ReplyInfo) -> io:format("~p", [ReplyInfo]) end}]).

Expected behavior Both request should have a result of the type {StatusCode, HttpBodyResult} However, first request has a result of the type {StatusCode, HttpBodyResult} but second request (async) has a result of the type {StatusLine, [HttpHeader], HttpBodyResult}

Either the return of async request should be {StatusCode, HttpBodyResult} or the documentation should be clarified.

Affected versions Latest

IngelaAndin commented 3 months ago

@Xavier59 hum we will look into it.

Whaileee commented 2 months ago

It appears that async mode doesn't support some of the options, but the solution is in progress currently