anchor.diff:          attachment -> wrq:set_resp_header("Content-Disposition", "attachment", ReqData);
           undefined ->  ReqData
       end,
  -    {Content, Context1} = case z_context:get(body, Context) of
  +    case z_context:get(body, Context) of
           undefined ->
  -            {ok, Data} = file:read_file(z_context:get(fullpath, Context)),
  -            Body = case z_context:get(encode_data, Context, false) of 
  -                true -> encode_data(Data);
  -                false -> Data
  -            end,
  -            {Body, z_context:set(body, Body, Context)};
  +            case z_context:get(chunked, Context) of
  +                true ->
  +                    {ok, Device} = file:open(z_context:get(fullpath, Context), [read,raw,binary]),
  +                    FileSize = z_context:get(file_size, Context),
  +                    {   {stream, read_chunk(0, FileSize, Device)}, 
  +                        wrq:set_resp_header("Content-Length", integer_to_list(FileSize), ReqData),
  +                        z_context:set(use_cache, false, Context) };
  +                _ ->
  +                    {ok, Data} = file:read_file(z_context:get(fullpath, Context)),
  +                    Body = case z_context:get(encode_data, Context, false) of 
  +                        true -> encode_data(Data);
  +                        false -> Data
  +                    end,
  +                    {Body, RD1, z_context:set(body, Body, Context)}
  +            end;
           Body -> 
  -            {Body, Context}
  -    end,
  -    {Content, RD1, Context1}.
  +            {Body, RD1, Context}
  +    end.
       
       
  +    read_chunk(Offset, Size, Device) when Offset =:= Size ->
  +        file:close(Device),
  +        {<<>>, done};
  +    read_chunk(Offset, Size, Device) when Size - Offset =< ?CHUNK_LENGTH ->
  +        {ok, Data} = file:read(Device, Size - Offset),
  +        file:close(Device),
  +        {Data, done};
  +    read_chunk(Offset, Size, Device) ->
  +        {ok, Data} = file:read(Device, ?CHUNK_LENGTH),
  +        {Data, fun() -> read_chunk(Offset+?CHUNK_LENGTH, Size, Device) end}.
  +
  +
   finish_request(ReqData, Context) ->
       case z_context:get(is_cached, Context) of
           false ->
  
positive.code: 
  
  encodings_provided(ReqData, Context) ->
      Encodings = case z_context:get(mime, Context) of
          "image/" ++ _ -> 
              [{"identity", fun(Data) -> Data end}];
          _ -> 
              [{"identity", fun(Data) -> decode_data(identity, Data) end},
               {"gzip",     fun(Data) -> decode_data(gzip, Data) end}]
      end,
      {Encodings, ReqData, z_context:set(encode_data, length(Encodings) > 1, Context)}.
  
  
negative.code: -record(cache, {path, fullpath, mime, last_modified, body}).
  
  -define(MAX_AGE, 315360000).
  -define(CHUNKED_CONTENT_LENGTH, 1048576).
  -define(CHUNK_LENGTH, 65536).
  
  init(ConfigProps) ->
      {ok, ConfigProps}.
  