anchor.diff:      catch Type:Message ->
           case Message of
               {sending_failed, Path} ->
  -                lager:error("Error while sending shared file ~p - ~p:~p~n~p", 
  +                lager:error("Error while sending shared file ~p - ~p:~p~n~p",
                       [Path, Type, Message, erlang:get_stacktrace()]);
               _ -> skip
           end,
  
positive.code: 
  parse_header(B) when is_binary(B) -> parse_header(binary_to_list(B));
  parse_header(String) ->
      [First|Rest] = [string:strip(S) || S <- string:tokens(String, ";")],
      {Name, Value} = parse_keyvalue($:, First),
      Params = [parse_keyvalue($=,X) || X <- Rest],
      Params1 = [{K,V} || {K,V} <- Params, K /= "", V /= ""],
      {Name, Value, Params1}.
  
  parse_keyvalue(Char, S) ->
      % If Char not found, then use an empty value...
      {Key, Value} = case string:chr(S, Char) of
          0   -> {S, ""};
          Pos -> {string:substr(S, 1, Pos - 1), string:substr(S, Pos + 1)}
      end,
      {string:to_lower(string:strip(Key)), 
          unquote_header(string:strip(Value))}.
  
  unquote_header("\"" ++ Rest) -> unquote_header(Rest, []);
  
negative.code: %% You can limit the size of the chunks being returned by using the
  %% first argument which is the size in bytes. It defaults to 1000000 bytes.
  -spec stream_body(non_neg_integer(), Req) -> {ok, binary(), Req}
  | {done, Req} | {error, atom()} when Req :: req().
  stream_body(MaxLength, Req = #http_req{body_state = waiting, version = Version,
      transport = Transport, socket = Socket}) ->
      {ok, ExpectHeader, Req1} = cowboy_req:parse_header(<<"expect">>, Req),
      case ExpectHeader of
          [<<"100-continue">>] ->
              HTTPVer = atom_to_binary(Version, latin1),
              Transport:send(Socket,
                  <<HTTPVer/binary, " ", (<<"100 Continue">>)/binary, "\r\n\r\n">>);
          undefined ->
              ok
      end,
      case cowboy_req:parse_header(<<"transfer-encoding">>, Req1) of
          {ok, [<<"chunked">>], Req2} ->
              stream_body(MaxLength, Req2#http_req{body_state =
              {stream, 0,
                  fun cowboy_http:te_chunked/2, {0, 0},
                  fun cowboy_http:ce_identity/1}});
          {ok, [<<"identity">>], Req2} ->
              {Length, Req3} = cowboy_req:body_length(Req2),
              case Length of
                  0 ->
                      {done, Req3#http_req{body_state = done}};
                  Length ->
                      stream_body(MaxLength, Req3#http_req{body_state =
                      {stream, Length,
                          fun cowboy_http:te_identity/2, {0, Length},
                          fun cowboy_http:ce_identity/1}})
              end
      end;
  stream_body(_, Req = #http_req{body_state = done}) ->
      {done, Req};
  stream_body(_, Req = #http_req{buffer = Buffer})
      when Buffer =/= <<>> ->
      transfer_decode(Buffer, Req#http_req{buffer = <<>>});
  stream_body(MaxLength, Req) ->
      stream_body_recv(MaxLength, Req).
  
  -spec stream_body_recv(non_neg_integer(), Req)
              -> {ok, binary(), Req} | {error, atom()} when Req :: req().
  stream_body_recv(MaxLength, Req = #http_req{
          transport = Transport, socket = Socket, buffer = Buffer,
          body_state = {stream, Length, _, _, _}}) ->
      %% @todo Allow configuring the timeout.
      case Transport:recv(Socket, min(Length, MaxLength), ?UPLOAD_PART_TIMEOUT) of
          {ok, Data} -> transfer_decode(<<Buffer/binary, Data/binary>>,
              Req#http_req{buffer = <<>>});
          {error, Reason} ->
              lager:error("Cannot recv upload part data with len: ~p due to: ~p", [min(Length, MaxLength), Reason]),
              {error, Reason}
      end.
  
  -spec transfer_decode(binary(), Req)
              -> {ok, binary(), Req} | {error, atom()} when Req :: req().
  transfer_decode(Data, Req = #http_req{body_state = {stream, _,
      TransferDecode, TransferState, ContentDecode}}) ->
      case TransferDecode(Data, TransferState) of
          {ok, Data2, Rest, TransferState2} ->
              content_decode(ContentDecode, Data2,
                  Req#http_req{buffer = Rest, body_state = {stream, 0,
                      TransferDecode, TransferState2, ContentDecode}});
      %% @todo {header(s) for chunked
          more ->
              stream_body_recv(0, Req#http_req{buffer = Data, body_state = {stream,
                  0, TransferDecode, TransferState, ContentDecode}});
          {more, Length, Data2, TransferState2} ->
              content_decode(ContentDecode, Data2,
                  Req#http_req{body_state = {stream, Length,
                      TransferDecode, TransferState2, ContentDecode}});
          {done, Length, Rest} ->
              Req2 = transfer_decode_done(Length, Rest, Req),
              {done, Req2};
  