anchor.diff:  
   send_response(Code, ReqData) ->
       Body0 = wrq:resp_body(ReqData),
  -    {Body,Length} = case Body0 of
  -        {stream, StreamBody} -> {{stream, StreamBody}, chunked};
  -        {writer, WriteBody} -> {{writer, WriteBody}, chunked};
  -        _ -> {Body0, iolist_size([Body0])}
  +    {Body, Transfer, Length} = case Body0 of
  +        {stream, StreamBody} -> {{stream, StreamBody}, chunked, undefined};
  +        {writer, WriteBody} -> {{writer, WriteBody}, chunked, undefined};
  +        {stream, StreamBody, KnownLength} -> {{stream, StreamBody}, chunked, KnownLength};
  +        {writer, WriteBody, KnownLength} -> {{writer, WriteBody}, chunked, KnownLength};
  +        _ -> {Body0, undefined, iolist_size([Body0])}
       end,
       send(ReqData#wm_reqdata.socket,
           [make_version(wrq:version(ReqData)),
            make_code(Code), <<"\r\n">> | 
  -         make_headers(Code, Length, ReqData)]),
  +         make_headers(Code, Transfer, Length, ReqData)]),
       FinalLength = case wrq:method(ReqData) of 
   	'HEAD' ->
   	    Length;
   	_ -> 
           case Body of
               {stream, Body2} ->
  -                send_stream_body(ReqData#wm_reqdata.socket, Body2);
  +                send_stream_body(ReqData#wm_reqdata.socket, is_chunked_transfer(wrq:version(ReqData), Transfer), Body2);
               {writer, Body2} ->
  -                send_writer_body(ReqData#wm_reqdata.socket, Body2);
  +                send_writer_body(ReqData#wm_reqdata.socket, is_chunked_transfer(wrq:version(ReqData), Transfer), Body2);
               _ ->
                   send(ReqData#wm_reqdata.socket, Body),
                   Length
  
positive.code:     FinalLogData = InitLogData#wm_log_data{response_code=Code,response_length=FinalLength},
      ReqData1 = wrq:set_response_code(Code, ReqData),
      {ok, ReqData1#wm_reqdata{log_data=FinalLogData}}.
  
  %% @doc  Infer body length from transfer-encoding and content-length headers.
  body_length(ReqData) ->
  
negative.code: make_version(_) ->
      <<"HTTP/1.1 ">>.
  
  make_headers(Code, Transfer, Length, RD) ->
      Hdrs0 = case Code of
          304 ->
              mochiweb_headers:make(wrq:resp_headers(RD));
          _ -> 
              LengthHeaders = case Length of
                  undefined ->
                      mochiweb_headers:make(wrq:resp_headers(RD));
                  _Length -> 
                      mochiweb_headers:enter(
                        "Content-Length",integer_to_list(Length),
                        mochiweb_headers:make(wrq:resp_headers(RD)))
              end,
              
              case is_chunked_transfer(wrq:version(RD), Transfer) of
                  true ->
                      mochiweb_headers:enter(
                        "Transfer-Encoding","chunked",
                        LengthHeaders);
                  false ->
                      LengthHeaders
              end
      end,
      ServerHeader = "MochiWeb/1.1 WebMachine/" ++ ?WMVSN ++ " Zotonic/" ++ ?ZOTONIC_VERSION,
  