Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'use_binaries' of git@github.com:Vagabond/gen_smtp into …

…use_binaries
  • Loading branch information...
commit ab3e06ca143da1abd8a0c4e3ecb89b897b6cbe94 2 parents be39498 + 1aa4498
Andrew Thompson authored
Showing with 7 additions and 7 deletions.
  1. +4 −4 src/gen_smtp_server_session.erl
  2. +3 −3 src/mimemail.erl
View
8 src/gen_smtp_server_session.erl
@@ -146,7 +146,7 @@ handle_info({receive_data, Body, Rest}, #state{socket = Socket, readmessage = tr
%Envelope = Env#envelope{data = list_to_binary(lists:reverse(Env#envelope.data))},
Valid = case has_extension(State#state.extensions, "SIZE") of
{true, Value} ->
- case size(Envelope#envelope.data) > list_to_integer(Value) of
+ case byte_size(Envelope#envelope.data) > list_to_integer(Value) of
true ->
socket:send(Socket, "552 Message too large\r\n"),
socket:active_once(Socket),
@@ -235,9 +235,9 @@ handle_info({_Proto, Socket, Packet}, #state{readmessage = true, envelope = Enve
Self = self(),
% receive in a child process
ExistingData = [Bin | Envelope#envelope.data],
- ExistingSize = lists:foldl(fun(E, A) -> A + size(E) end, 0, ExistingData),
+ ExistingSize = lists:foldl(fun(E, A) -> A + byte_size(E) end, 0, ExistingData),
- HeaderSize = lists:foldl(fun({K, V}, A) -> size(K) + size(V) + A end, 0, Envelope#envelope.headers),
+ HeaderSize = lists:foldl(fun({K, V}, A) -> byte_size(K) + byte_size(V) + A end, 0, Envelope#envelope.headers),
Size = HeaderSize + ExistingSize,
@@ -767,7 +767,7 @@ receive_data(Acc, Socket, {OldCount, OldRecvSize}, Size, MaxSize, Session) ->
0 ->
%io:format("received ~B bytes; size is now ~p~n", [RecvSize, Size + size(Packet)]),
%io:format("memory usage: ~p~n", [erlang:process_info(self(), memory)]),
- receive_data([Packet | Acc], Socket, {Count, RecvSize}, Size + size(Packet), MaxSize, Session);
+ receive_data([Packet | Acc], Socket, {Count, RecvSize}, Size + byte_size(Packet), MaxSize, Session);
Index ->
String = binstr:substr(Packet, 1, Index - 1),
Rest = binstr:substr(Packet, Index+5),
View
6 src/mimemail.erl
@@ -191,10 +191,10 @@ split_body_by_boundary(Body, Boundary, MimeVsn) ->
[Start, End] when Start =:= 0; End =:= 0 ->
erlang:error(bad_boundary);
[Start, End] ->
- NewBody = binstr:substr(Body, Start + size(Boundary), End - Start),
+ NewBody = binstr:substr(Body, Start + byte_size(Boundary), End - Start),
% from now on, we can be sure that each boundary is preceeded by a CRLF
Parts = split_body_by_boundary_(NewBody, list_to_binary(["\r\n", Boundary]), []),
- Res = lists:filter(fun({Headers, Body2}) -> size(Body2) =/= 0 end, Parts),
+ Res = lists:filter(fun({Headers, Body2}) -> byte_size(Body2) =/= 0 end, Parts),
lists:map(fun({Headers, Body2}) -> decode_component(Headers, Body2, MimeVsn) end, Res)
end.
@@ -207,7 +207,7 @@ split_body_by_boundary_(Body, Boundary, Acc) ->
0 ->
lists:reverse([{[], TrimmedBody} | Acc]);
Index ->
- split_body_by_boundary_(binstr:substr(TrimmedBody, Index + size(Boundary)), Boundary,
+ split_body_by_boundary_(binstr:substr(TrimmedBody, Index + byte_size(Boundary)), Boundary,
[parse_headers(binstr:substr(TrimmedBody, 1, Index - 1)) | Acc])
end.
Please sign in to comment.
Something went wrong with that request. Please try again.