aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/gen_tcp.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-11-25 20:29:59 +0100
committerLukas Larsson <[email protected]>2011-12-01 14:10:06 +0100
commita5b3d81936ab85edb8713f29baf85307ae0b25b8 (patch)
treee3905e38972d900084858312b01af56ac0b87bc1 /lib/kernel/src/gen_tcp.erl
parent9322161952ed25a96578f163cc383be605e7f75c (diff)
downloadotp-a5b3d81936ab85edb8713f29baf85307ae0b25b8.tar.gz
otp-a5b3d81936ab85edb8713f29baf85307ae0b25b8.tar.bz2
otp-a5b3d81936ab85edb8713f29baf85307ae0b25b8.zip
Preliminary work on header/trailer
Have to figure out how to represent progress in header writing when using non-blocking, not sure how to do this.
Diffstat (limited to 'lib/kernel/src/gen_tcp.erl')
-rw-r--r--lib/kernel/src/gen_tcp.erl14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl
index 2eaa44b966..78e3ab3697 100644
--- a/lib/kernel/src/gen_tcp.erl
+++ b/lib/kernel/src/gen_tcp.erl
@@ -327,7 +327,7 @@ unrecv(S, Data) when is_port(S) ->
sendfile(File, _Sock, _Offet, _Bytes, _Opts) when is_pid(File) ->
{error, badarg};
sendfile(File, Sock, Offset, Bytes, []) ->
- sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, undefined, undefined,
+ sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, [], [],
false, false, false);
sendfile(File, Sock, Offset, Bytes, Opts) ->
ChunkSize0 = proplists:get_value(chunk_size, Opts, ?MAX_CHUNK_SIZE),
@@ -335,8 +335,8 @@ sendfile(File, Sock, Offset, Bytes, Opts) ->
?MAX_CHUNK_SIZE;
true -> ChunkSize0
end,
- Headers = proplists:get_value(headers, Opts),
- Trailers = proplists:get_value(trailers, Opts),
+ Headers = proplists:get_value(headers, Opts, []),
+ Trailers = proplists:get_value(trailers, Opts, []),
sendfile(File, Sock, Offset, Bytes, ChunkSize, Headers, Trailers,
lists:member(sf_nodiskio,Opts),lists:member(sf_mnowait,Opts),
lists:member(sf_sync,Opts)).
@@ -432,11 +432,13 @@ sendfile(_,_,_,_,_,_,_,_,_,_) ->
%%%
sendfile_fallback(File, Sock, Offset, Bytes, ChunkSize,
Headers, Trailers)
- when is_list(Headers) == false ->
+ when Headers == []; is_integer(Headers) ->
case sendfile_fallback(File, Sock, Offset, Bytes, ChunkSize) of
- {ok, BytesSent} when is_list(Trailers),is_integer(Headers) ->
+ {ok, BytesSent} when is_list(Trailers),
+ Trailers =/= [],
+ is_integer(Headers) ->
sendfile_send(Sock, Trailers, BytesSent+Headers);
- {ok, BytesSent} when is_list(Trailers) ->
+ {ok, BytesSent} when is_list(Trailers), Trailers =/= [] ->
sendfile_send(Sock, Trailers, BytesSent);
{ok, BytesSent} when is_integer(Headers) ->
{ok, BytesSent + Headers};