diff options
author | Lukas Larsson <[email protected]> | 2011-11-25 20:29:59 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2011-12-01 14:10:06 +0100 |
commit | a5b3d81936ab85edb8713f29baf85307ae0b25b8 (patch) | |
tree | e3905e38972d900084858312b01af56ac0b87bc1 /lib | |
parent | 9322161952ed25a96578f163cc383be605e7f75c (diff) | |
download | otp-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')
-rw-r--r-- | lib/kernel/src/gen_tcp.erl | 14 | ||||
-rw-r--r-- | lib/kernel/test/gen_tcp_api_SUITE.erl | 2 |
2 files changed, 9 insertions, 7 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}; diff --git a/lib/kernel/test/gen_tcp_api_SUITE.erl b/lib/kernel/test/gen_tcp_api_SUITE.erl index 876d266c4b..d66caad2d8 100644 --- a/lib/kernel/test/gen_tcp_api_SUITE.erl +++ b/lib/kernel/test/gen_tcp_api_SUITE.erl @@ -370,7 +370,7 @@ t_sendfile_hdtl(Config) -> end, SendHdTl = fun(Sock) -> - Headers = [<<"header1">>,"header2"], + Headers = [<<"header1">>,<<0:(1024*8)>>,"header2"], Trailers = [<<"trailer1">>,"trailer2"], D = Send(Sock,Headers,Trailers, iolist_size([Headers,Trailers])), |