anchor.diff:      StreamEnd = lxmppc_stanza:stream_end(),
       send0(transport(State), exml:to_iolist(StreamEnd), State),
       {stop, normal, ok, State}.
  -
  -handle_cast({send, Transport, Elem}, #state{owner=Owner, rid=Rid} = State) when
  +handle_cast(stop, State) ->
  +    {stop, normal, State};
  +handle_cast({send, Transport, Elem}, #state{rid=Rid} = State) when
           is_record(Elem, xmlstreamstart) ->
           InitBody = send0(Transport, Elem, State),
           NewState = State#state{rid=Rid+1,
  
positive.code: %%% Helpers
  %%%===================================================================
  send0(#transport{socket = {Host, Port, Path}} = Transport, Elem0, #state{parser = Parser} = State) ->
      Headers = [{"Content-Type", "text/xml; charset-utf-8"}],
      Elem = wrap_elem(Elem0, State),
      {ok, {{StatusCode, Reason}, Hdrs, RespBody}} =
          lhttpc:request(Host, Port, false, Path, 'POST',
  
negative.code:                compress = false,
                 rcv_pid = self()}.
  
  wrap_elem(#xmlstreamstart{attrs=Attrs}, #state{rid=Rid, sid=Sid}) ->
      Version = proplists:get_value(<<"version">>, Attrs, <<"1.0">>),
      Lang = proplists:get_value(<<"xml:lang">>, Attrs, <<"en">>),
      To = proplists:get_value(<<"to">>, Attrs, <<"localhost">>),
      #xmlelement{name = <<"body">>, attrs=common_attrs(Rid, Sid) ++ [
              {<<"content">>, <<"text/xml; charset=utf-8">>},
              {<<"xmlns:xmpp">>, <<"urn:xmpp:xbosh">>},
              {<<"xmpp:version">>, <<"1.0">>},
              {<<"hold">>, <<"1">>},
              {<<"wait">>, <<"60">>},
              {<<"xml:lang">>, Lang},
              {<<"to">>, To}
              ] ++ [{<<"xmpp:restart">>, <<"true">>} || Sid =/= nil]};
  
  wrap_elem(["</", <<"stream:stream">>, ">"], #state{sid=Sid, rid=Rid}) ->
      #xmlelement{name = <<"body">>, 
                  attrs = common_attrs(Rid, Sid) ++ [{<<"type">>, <<"terminate">>}],
  