Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tie yaws_sendfile_compat into yaws_server

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1306 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
commit fe0e677b4b4d7e10b0558b5fe9469b62c53c50b1 1 parent 12471ad
@vinoski vinoski authored
Showing with 12 additions and 39 deletions.
  1. +1 −1  src/Makefile
  2. +5 −5 src/yaws_sendfile_compat.erl
  3. +6 −33 src/yaws_server.erl
View
2  src/Makefile
@@ -49,7 +49,7 @@ ERLC_FLAGS+=-W $(DEBUG_FLAGS) -pa ../../yaws -I ../include
# Targets
#
-all: yaws_generated.erl $(EBIN_FILES)
+all: yaws_generated.erl yaws_configure.hrl $(EBIN_FILES)
dav:
$(MAKE) MODULES="$(MODULES) yaws_dav"
View
10 src/yaws_sendfile_compat.erl
@@ -34,7 +34,7 @@ send(Out, FileName, Offset, Count) ->
enabled() ->
false.
start_link() ->
- ignore;
+ ignore.
stop() ->
ok.
init(_) ->
@@ -42,14 +42,14 @@ init(_) ->
send(Out, Filename) ->
send(Out, Filename, 0, all).
send(Out, Filename, Offset) ->
- sendfile(Out, Filename, Offset, all).
+ send(Out, Filename, Offset, all).
send(Out, Filename, Offset, Count) ->
case file:open(Filename, [read, raw]) of
{ok, Fd} ->
file:position(Fd, {bof, Offset}),
Ret = loop_send(Fd, file:read(Fd, 2048), Out, Count),
file:close(Fd),
- retl
+ Ret;
Err ->
Err
end.
@@ -61,7 +61,7 @@ loop_send(Fd, {ok, Bin}, Out, all) ->
Err ->
Err
end;
-loop_send(Fd, eof, Out, _) ->
+loop_send(_Fd, eof, _Out, _) ->
ok;
loop_send(Fd, {ok, Bin}, Out, Count) ->
Sz = size(Bin),
@@ -78,7 +78,7 @@ loop_send(Fd, {ok, Bin}, Out, Count) ->
<<Deliver:Count/binary , _/binary>> = Bin,
gen_tcp:send(Deliver, Count)
end;
-loop_send(Fd, Err, _,_) ->
+loop_send(_Fd, Err, _,_) ->
Err.
View
39 src/yaws_server.erl
@@ -3019,43 +3019,16 @@ deliver_large_file(CliSock, _Req, UT, Range) ->
discard ->
ok;
Priv ->
- {ok,Fd} = file:open(UT#urltype.fullpath, [raw, binary, read]),
- send_file(CliSock, Fd, Range, Priv)
+ send_file(CliSock, UT#urltype.fullpath, Range, Priv)
end,
done_or_continue().
-send_file(CliSock, Fd, all, Priv) ->
- send_file(CliSock, Fd, Priv);
-send_file(CliSock, Fd, {fromto, From, To, _Tot}, undeflated) ->
- file:position(Fd, {bof, From}),
- send_file_range(CliSock, Fd, To - From + 1).
-
-
-send_file(CliSock, Fd, Priv) ->
- ?Debug("send_file(~p,~p, ...)~n",
- [CliSock, Fd]),
- case file:read(Fd, (get(gc))#gconf.large_file_chunk_size) of
- {ok, Bin} ->
- Priv1 = send_streamcontent_chunk(Priv, CliSock, Bin),
- send_file(CliSock, Fd, Priv1);
- eof ->
- file:close(Fd),
- end_streaming(Priv, CliSock)
- end.
-
-send_file_range(CliSock, Fd, Len) when Len > 0 ->
- {ok, Bin} = file:read(Fd,
- case (get(gc))#gconf.large_file_chunk_size of
- S when S < Len -> S;
- _ -> Len
- end
- ),
- send_streamcontent_chunk(undeflated, CliSock, Bin),
- send_file_range(CliSock, Fd, Len - size(Bin));
-send_file_range(CliSock, Fd, 0) ->
- file:close(Fd),
- end_streaming(undeflated, CliSock).
+send_file(CliSock, Path, all, _Priv) ->
+ ?Debug("send_file(~p,~p, ...)~n", [CliSock, Path]),
+ yaws_sendfile_compat:send(CliSock, Path);
+send_file(CliSock, Path, {fromto, From, To, _Tot}, undeflated) ->
+ yaws_sendfile_compat:send(CliSock, Path, From, 1+To-From).
crnl() ->
Please sign in to comment.
Something went wrong with that request. Please try again.