anchor.diff:          undefined ->
               TransferEncoding =  dlhttpc_lib:header_value(<<"Transfer-encoding">>, Hdrs, "undefined"),
               case TransferEncoding of
  +                <<"Chunked">> -> chunked;
                   <<"chunked">> -> chunked;
                   _         -> infinite
               end;
  
positive.code: check_infinite_response({1, Minor}, Hdrs) when Minor >= 1 ->
      HdrValue = dlhttpc_lib:header_value(<<"Connection">>, Hdrs, <<"keep-alive">>),
      case HdrValue of
          <<"close">> -> ok;
          _       -> erlang:error(no_content_length)
      end;
  check_infinite_response(_, Hdrs) ->
      HdrValue = dlhttpc_lib:header_value(<<"Connection">>, Hdrs, <<"close">>),
      case HdrValue of
          <<"keep-alive">> -> erlang:error(no_content_length);
          _            -> ok
      end.
  
negative.code:     end.
  
  maybe_close_socket(Socket, Ssl, {1, Minor}, ReqHdrs, RespHdrs) when Minor >= 1->
      ClientConnection = ?CONNECTION_HDR(ReqHdrs, <<"keep-alive">>),
      ServerConnection = ?CONNECTION_HDR(RespHdrs, <<"keep-alive">>),
      case {closed(ClientConnection), closed(ServerConnection)} of
          {true, _} ->
              dlhttpc_sock:close(Socket, Ssl),
              undefined;
          {_, true} ->
              dlhttpc_sock:close(Socket, Ssl),
              undefined;
          _Else ->
              Socket
      end;
  maybe_close_socket(Socket, Ssl, _, ReqHdrs, RespHdrs) ->
      ClientConnection = ?CONNECTION_HDR(ReqHdrs, <<"keep-alive">>),
      ServerConnection = ?CONNECTION_HDR(RespHdrs, <<"close">>),
      case {closed(ClientConnection), keep_alive(ServerConnection)} of
          {false, true} ->
              Socket;
          _Else ->
              dlhttpc_sock:close(Socket, Ssl),
              undefined
      end.
  
  closed(HeaderValue) ->
      case HeaderValue of
          <<"Close">> -> true;
          <<"close">> -> true;
          _Else -> false
      end.
  
  keep_alive(HeaderValue) ->
      case HeaderValue of
          <<"Keep-Alive">> -> true;
          <<"keep-alive">> -> true;
          _Else -> false
      end.
  