diff options
author | Kiko Fernandez-Reyes <kiko@erlang.org> | 2023-01-16 14:54:55 +0100 |
---|---|---|
committer | Kiko Fernandez-Reyes <kiko@erlang.org> | 2023-01-16 14:54:55 +0100 |
commit | 9c4b96630391092cff2d7cd7993924673482c633 (patch) | |
tree | 29494da4a9957777472483b13d80a4b7ca06de8b /lib/inets/src | |
parent | bdf564f8ee2ef847a33dded0f30bb9073779ace7 (diff) | |
parent | 2a49eb7a8ac9f24b7305d98871934d77595651f2 (diff) | |
download | erlang-9c4b96630391092cff2d7cd7993924673482c633.tar.gz |
Merge branch 'maint'
Diffstat (limited to 'lib/inets/src')
-rw-r--r-- | lib/inets/src/http_client/httpc.erl | 2 | ||||
-rw-r--r-- | lib/inets/src/http_client/httpc_handler.erl | 18 | ||||
-rw-r--r-- | lib/inets/src/http_client/httpc_request.erl | 2 | ||||
-rw-r--r-- | lib/inets/src/http_client/httpc_response.erl | 8 | ||||
-rw-r--r-- | lib/inets/src/http_lib/http_chunk.erl | 6 | ||||
-rw-r--r-- | lib/inets/src/http_lib/http_transport.erl | 8 | ||||
-rw-r--r-- | lib/inets/src/http_server/httpd_request.erl | 16 | ||||
-rw-r--r-- | lib/inets/src/http_server/mod_cgi.erl | 8 |
8 files changed, 34 insertions, 34 deletions
diff --git a/lib/inets/src/http_client/httpc.erl b/lib/inets/src/http_client/httpc.erl index a4b6092941..e1c92fea4e 100644 --- a/lib/inets/src/http_client/httpc.erl +++ b/lib/inets/src/http_client/httpc.erl @@ -1340,7 +1340,7 @@ validate_ipfamily(BadValue) -> bad_option(ipfamily, BadValue). validate_ip(Value) - when is_tuple(Value) andalso ((size(Value) =:= 4) orelse (size(Value) =:= 8)) -> + when tuple_size(Value) =:= 4; tuple_size(Value) =:= 8 -> Value; validate_ip(BadValue) -> bad_option(ip, BadValue). diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index b7f79a5ed3..61e977777b 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -50,12 +50,12 @@ -record(state, { - request :: request() | 'undefined', - session :: session() | 'undefined', - status_line, % {Version, StatusCode, ReasonPharse} - headers :: http_response_h() | 'undefined', - body :: binary() | 'undefined', - mfa, % {Module, Function, Args} + request :: request() | undefined, + session :: session() | undefined, + status_line :: tuple() | undefined, % {Version, StatusCode, ReasonPharse} + headers :: http_response_h() | undefined, + body :: binary() | undefined, + mfa :: {atom(), atom(), term()} | undefined, % {Module, Function, Args} pipeline = queue:new() :: queue:queue(), keep_alive = queue:new() :: queue:queue(), status :: undefined | new | pipeline | keep_alive | close | {ssl_tunnel, request()}, @@ -65,7 +65,7 @@ options :: options(), timers = #timers{} :: #timers{}, profile_name :: atom(), % id of httpc_manager process. - once = inactive :: 'inactive' | 'once' + once = inactive :: inactive | once }). @@ -515,7 +515,7 @@ do_handle_info({Proto, _Socket, Data}, handle_http_msg(Result, State); {_, whole_body, _} when Method =:= head -> handle_response(State#state{body = <<>>}); - {Module, whole_body, [Body, Length]} -> + {Module, whole_body, [Body, Length]} when is_binary(Body)-> {_, Code, _} = StatusLine, {Streamed, NewBody, NewRequest} = stream(Body, Request, Code), %% When we stream we will not keep the already @@ -525,7 +525,7 @@ do_handle_info({Proto, _Socket, Data}, false -> Length; true -> - Length - size(Body) + Length - byte_size(Body) end, NewState = next_body_chunk(State, Code), diff --git a/lib/inets/src/http_client/httpc_request.erl b/lib/inets/src/http_client/httpc_request.erl index b765da98a0..2c906b5294 100644 --- a/lib/inets/src/http_client/httpc_request.erl +++ b/lib/inets/src/http_client/httpc_request.erl @@ -241,7 +241,7 @@ handle_transfer_encoding(Headers) -> Headers#http_request_h{'content-length' = undefined}. body_length(Body) when is_binary(Body) -> - integer_to_list(size(Body)); + integer_to_list(byte_size(Body)); body_length(Body) when is_list(Body) -> integer_to_list(iolist_size(Body)). diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl index ab57c16153..b0a21cc3aa 100644 --- a/lib/inets/src/http_client/httpc_response.erl +++ b/lib/inets/src/http_client/httpc_response.erl @@ -60,8 +60,8 @@ parse_headers([Bin, Rest,Header, Headers, MaxHeaderSize, Result, Relaxed]) -> parse_headers(<<Rest/binary, Bin/binary>>, Header, Headers, MaxHeaderSize, Result, Relaxed). -whole_body(Body, Length) -> - case size(Body) of +whole_body(Body, Length) when is_binary(Body)-> + case byte_size(Body) of N when (N < Length) andalso (N > 0) -> {?MODULE, whole_body, [Body, Length]}; %% OBS! The Server may close the connection to indicate that the @@ -592,13 +592,13 @@ is_server_closing(Headers) when is_record(Headers, http_response_h) -> format_response({StatusLine, Headers, Body = <<>>}) -> {{StatusLine, http_response:header_list(Headers), Body}, <<>>}; -format_response({StatusLine, Headers, Body}) -> +format_response({StatusLine, Headers, Body}) when is_binary(Body) -> Length = list_to_integer(Headers#http_response_h.'content-length'), {NewBody, Data} = case Length of -1 -> % When no length indicator is provided {Body, <<>>}; - Length when (Length =< size(Body)) -> + Length when (Length =< byte_size(Body)) -> <<BodyThisReq:Length/binary, Next/binary>> = Body, {BodyThisReq, Next}; _ -> %% Connection prematurely ended. diff --git a/lib/inets/src/http_lib/http_chunk.erl b/lib/inets/src/http_lib/http_chunk.erl index 74f4cc1b3d..90c5f68bd0 100644 --- a/lib/inets/src/http_lib/http_chunk.erl +++ b/lib/inets/src/http_lib/http_chunk.erl @@ -71,8 +71,8 @@ decode(ChunkedBody, MaxBodySize, MaxHeaderSize) -> %% input format. When sending the data on the both formats %% are accepted. %%------------------------------------------------------------------------- -encode(Chunk) when is_binary(Chunk)-> - HEXSize = list_to_binary(http_util:integer_to_hexlist(size(Chunk))), +encode(Chunk) when is_binary(Chunk) -> + HEXSize = list_to_binary(http_util:integer_to_hexlist(byte_size(Chunk))), <<HEXSize/binary, ?CR, ?LF, Chunk/binary, ?CR, ?LF>>; encode([<<>>]) -> @@ -202,7 +202,7 @@ ignore_extensions(<<_Octet, Rest/binary>>, RemainingSize, TotalMaxHeaderSize, Ne decode_data(ChunkSize, TotalChunk, Info = {MaxBodySize, BodySoFar, AccLength, MaxHeaderSize}) - when ChunkSize =< size(TotalChunk) -> + when is_binary(TotalChunk), ChunkSize =< byte_size(TotalChunk) -> case TotalChunk of %% Last chunk <<Data:ChunkSize/binary, ?CR, ?LF, "0", ";">> -> diff --git a/lib/inets/src/http_lib/http_transport.erl b/lib/inets/src/http_lib/http_transport.erl index 34f1aadc58..89e782afe2 100644 --- a/lib/inets/src/http_lib/http_transport.erl +++ b/lib/inets/src/http_lib/http_transport.erl @@ -403,11 +403,11 @@ peername({essl, _}, Socket) -> do_peername(ssl:peername(Socket)). do_peername({ok, {Addr, Port}}) - when is_tuple(Addr) andalso (size(Addr) =:= 4) -> + when tuple_size(Addr) =:= 4 -> PeerName = ipv4_name(Addr), {Port, PeerName}; do_peername({ok, {Addr, Port}}) - when is_tuple(Addr) andalso (size(Addr) =:= 8) -> + when tuple_size(Addr) =:= 8 -> PeerName = ipv6_name(Addr), {Port, PeerName}; do_peername({error, _}) -> @@ -436,11 +436,11 @@ sockname({essl, _}, Socket) -> do_sockname(ssl:sockname(Socket)). do_sockname({ok, {Addr, Port}}) - when is_tuple(Addr) andalso (size(Addr) =:= 4) -> + when tuple_size(Addr) =:= 4 -> SockName = ipv4_name(Addr), {Port, SockName}; do_sockname({ok, {Addr, Port}}) - when is_tuple(Addr) andalso (size(Addr) =:= 8) -> + when tuple_size(Addr) =:= 8 -> SockName = ipv6_name(Addr), {Port, SockName}; do_sockname({error, _}) -> diff --git a/lib/inets/src/http_server/httpd_request.erl b/lib/inets/src/http_server/httpd_request.erl index a16df6914a..7df2ed08f1 100644 --- a/lib/inets/src/http_server/httpd_request.erl +++ b/lib/inets/src/http_server/httpd_request.erl @@ -71,9 +71,9 @@ whole_body([Bin, Body, Length]) -> %% Separate the body for this request from a possible piplined new %% request and convert the body data to "string" format. -body_data(Headers, Body) -> +body_data(Headers, Body) when is_binary(Body)-> ContentLength = list_to_integer(Headers#http_request_h.'content-length'), - case size(Body) - ContentLength of + case byte_size(Body) - ContentLength of 0 -> {Body, <<>>}; _ -> @@ -305,24 +305,24 @@ body_chunk(Body, Length, nolimit) -> body_chunk(<<>> = Body, Length, MaxChunk) -> {ok, {continue, ?MODULE, add_chunk, [Body, Length, MaxChunk]}}; -body_chunk(Body, Length, MaxChunk) when Length > MaxChunk -> - case size(Body) >= MaxChunk of +body_chunk(Body, Length, MaxChunk) when Length > MaxChunk, is_binary(Body) -> + case byte_size(Body) >= MaxChunk of true -> <<Chunk:MaxChunk/binary, Rest/binary>> = Body, {ok, {{continue, Chunk}, ?MODULE, add_chunk, [Rest, Length - MaxChunk, MaxChunk]}}; false -> {ok, {continue, ?MODULE, add_chunk, [Body, Length, MaxChunk]}} end; -body_chunk(Body, Length, MaxChunk) -> - case size(Body) of +body_chunk(Body, Length, MaxChunk) when is_binary(Body)-> + case byte_size(Body) of Length -> {ok, {last, Body}}; _ -> {ok, {continue, ?MODULE, add_chunk, [Body, Length, MaxChunk]}} end. -whole_body(Body, Length) -> - case size(Body) of +whole_body(Body, Length) when is_binary(Body)-> + case byte_size(Body) of N when N < Length, Length > 0 -> {?MODULE, add_chunk, [Body, Length, nolimit]}; N when N >= Length, Length >= 0 -> diff --git a/lib/inets/src/http_server/mod_cgi.erl b/lib/inets/src/http_server/mod_cgi.erl index d961ac655f..13d5e6f81d 100644 --- a/lib/inets/src/http_server/mod_cgi.erl +++ b/lib/inets/src/http_server/mod_cgi.erl @@ -208,7 +208,7 @@ deliver_webpage(#mod{config_db = Db} = ModData, Port) -> {proceed, [{real_name, httpd_util:split_path(AbsPath)} | ModData#mod.data]}; - {ok, HTTPHeaders, Status} -> + {ok, HTTPHeaders, Status} when is_binary(Body)-> IsDisableChunkedSend = httpd_response:is_disable_chunked_send(Db), case (ModData#mod.http_version =/= "HTTP/1.1") or @@ -222,7 +222,7 @@ deliver_webpage(#mod{config_db = Db} = ModData, Port) -> [{"transfer-encoding", "chunked"} | HTTPHeaders]) end, - handle_body(Port, ModData, Body, Timeout, size(Body), + handle_body(Port, ModData, Body, Timeout, byte_size(Body), IsDisableChunkedSend) end; {'EXIT', Port, Reason} -> @@ -268,8 +268,8 @@ handle_body(Port, #mod{method = "HEAD"} = ModData, _, _, Size, _) -> handle_body(Port, ModData, Body, Timeout, Size, IsDisableChunkedSend) -> httpd_response:send_chunk(ModData, Body, IsDisableChunkedSend), receive - {Port, {data, Data}} when is_port(Port) -> - handle_body(Port, ModData, Data, Timeout, Size + size(Data), + {Port, {data, Data}} when is_port(Port), is_binary(Data) -> + handle_body(Port, ModData, Data, Timeout, Size + byte_size(Data), IsDisableChunkedSend); {'EXIT', Port, normal} when is_port(Port) -> httpd_response:send_final_chunk(ModData, IsDisableChunkedSend), |