anchor.diff:      parse_range({erlang:max(Size - SuffixLength, 0), SuffixLength}, Size);
   parse_range(<<$b,$y,$t,$e,$s,$=, ByteRange/binary>>, Size) ->
       case binary:split(ByteRange, <<"-">>) of
  -	%% byte-range without last-byte-pos
  -	[FirstBytePosBin, <<>>] ->
  -	    parse_range({?b2i(FirstBytePosBin), Size}, Size);
  -	%% full byte-range
  -	[FirstBytePosBin, LastBytePosBin] ->
  -	    First = ?b2i(FirstBytePosBin),
  -	    Last = ?b2i(LastBytePosBin),
  -	    parse_range({First, Last - First + 1}, Size);
  -	_ -> invalid
  +        %% byte-range without last-byte-pos
  +        [FirstBytePosBin, <<>>] ->
  +            parse_range({?b2i(FirstBytePosBin), Size}, Size);
  +        %% full byte-range
  +        [FirstBytePosBin, LastBytePosBin] ->
  +            First = ?b2i(FirstBytePosBin),
  +            Last = ?b2i(LastBytePosBin),
  +            parse_range({First, Last - First + 1}, Size);
  +        _ -> invalid
       end;
   parse_range({Offset, Length}, Size)
     when Offset < 0; Offset >= Size; Length =< 0; Size =< 0 -> invalid;
  
positive.code: 
  
  -spec send_file(Socket::inet:socket(), RequestHeaders::headers(),
  		Code::response_code(), Headers::headers(), Filename::file:filename(),
  		Opts::proplists:proplist(), Callback::callback()) -> ok.
  
  %% @doc: Generates and sends a HTTP response to the client where the body
  %% is the contents of the given file. Supports single byte-range requests.
  send_file(Socket, RequestHeaders, Code, Headers, Filename, Opts, {Mod, Args}) ->
      Size = case proplists:get_value(size, Opts) of
  	       undefined -> get_size(Filename);
  	       Size0     -> Size0
  	   end,
      Range = case proplists:get_value(range, Opts) of
  		undefined -> get_range(RequestHeaders, Size);
  		Range0    -> Range0
  	    end,
      Headers0 = set_range_and_length(Range, Size, Headers),
      %% Rewrite status code when a (in)valid range is present.
      Code0 = case Range of
  		undefined -> Code;
  		{_,_}     -> 206;
  		invalid   -> 416
  	    end,
  
      ResponseHeaders = [<<"HTTP/1.1 ">>, status(Code0), <<"\r\n">>,
  		       encode_headers(Headers0), <<"\r\n">>],
      case gen_tcp:send(Socket, ResponseHeaders) of
  	ok ->
  	    case send_file(Socket, Filename, Range) of
  		{ok, _BytesSent} -> ok;
  		{error, closed} ->
  		    Mod:handle_event(client_closed, [before_response], Args),
  		    ok;
  		{error, invalid_range} ->
  		    Mod:handle_event(requested_range_not_satisfiable, [], Args),
  		    ok
  	    end;
  	{error, closed} ->
  	    Mod:handle_event(client_closed, [before_response], Args),
  	    ok
      end.
  
  send_file(Socket, Filename, {Offset, Bytes}) ->
      case file:open(Filename, [read, raw, binary]) of
  	{ok, Fd} ->
  	    Res = file:sendfile(Fd, Socket, Offset, Bytes, []),
  	    file:close(Fd),
  	    Res;
  	{error, Reason} ->
  	    {error, Reason}
      end;
  %% When range is undefined, set both offset and bytes to 0,
  %% which sends the entire file.
  
negative.code:     end.
  
  -spec get_range(RequestHeaders::headers(),
                  Size::non_neg_integer()) -> byte_range().
  
  %% @doc: Parses the Range header from the request, if present,
  %% as defined in rfc2616-14.35.1. At the moment only
  