anchor.diff:              State
       end,
       Stanzas = unwrap_elem(Body),
  +    case State#state.active of
  +        true ->
  +            forward_to_owner(Stanzas, NewState),
  +            NewState;
  +        false ->
  +            store_reply(Body, NewState)
  +    end.
  +
  +forward_to_owner(Stanzas, #state{owner = Owner} = S) ->
       lists:foreach(fun(Stanza) ->
  -        Owner ! {stanza, transport(NewState), Stanza}
  +        Owner ! {stanza, transport(S), Stanza}
       end, Stanzas),
       case lists:keyfind(xmlstreamend, 1, Stanzas) of
           false ->
               ok;
           _ ->
               gen_server:cast(self(), stop)
  +    end.
  +
  +store_reply(Body, #state{replies = Replies} = S) ->
  +    S#state{replies = Replies ++ [Body]}.
  +
  +handle_recv(#state{replies = []} = S) ->
  +    {empty, S};
  +handle_recv(#state{replies = [Reply | Replies]} = S) ->
  +    case Reply of
  +        #xmlstreamend{} ->
  +            gen_server:cast(self(), stop);
  +        _ -> ok
       end,
  -    NewState.
  +    {Reply, S#state{replies = Replies}}.
   
   transport(#state{url = Url}) ->
       #transport{module = ?MODULE,
  
positive.code: 
  handle_data(<<>>, State) ->
      State;
  handle_data(Data, #state{owner = Owner} = State) ->
      {ok, Body} = exml:parse(Data),
      NewState = case State#state.sid of
          %% First reply for this transport, set sid
  
negative.code:                 rid = nil,
                  requests = 0,
                  keepalive = true,
                  wait,
                  active = true,
                  replies = []}).
  
  %%%===================================================================
  %%% API
  