anchor.diff:                  undefined ->
                       {error, missing_host_param};
                   Host ->
  -                    logplex_tcpsyslog_drain:uri(Host, Port)
  +                     logplex_drain:valid_uri(logplex_tcpsyslog_drain:uri(Host, Port))
               end;
           UrlString ->
  -            logplex_drain:parse_url(UrlString)
  -    end.
  -
  -json_error(Code, Err) ->
  -    {Code, ?JSON_CONTENT,
  -     mochijson2:encode({struct, [{error, iolist_to_binary(Err)}]})}.
  -
  -api_relative_url(_APIVSN, UUID) when is_binary(UUID) ->
  -    iolist_to_binary([<<"/sessions/">>, UUID]).
  -
  -end_chunked_response(Socket) ->
  -    gen_tcp:close(Socket),
  -    ok.
  -
  -uri_to_binary(Uri) ->
  -    iolist_to_binary(ex_uri:encode(Uri)).
  +            try
  +                logplex_drain:valid_uri(
  +                  logplex_drain:parse_url(UrlString))
  +            catch
  +                error:badarg ->
  +                    {error, UrlString}
  +            end            
  +    end.
  +
  +   
  
positive.code:             {error, timeout} ->
                  json_error(404, <<"Unknown drain.">>);
              Token when is_binary(Token) ->
                  case logplex_drain:valid_uri(req_drain_uri(Req)) of
                      {error, What} ->
                          logplex_drain:delete_partial_drain(DrainId, Token),
                          Err = io_lib:format("Invalid drain destination: ~p",
  
negative.code:     Json = {struct, [{error, <<"Not found">>}]},
      {404, iolist_to_binary(mochijson2:encode(Json))}.
  
  json_error(Code, Err) ->
      {Code, ?JSON_CONTENT,
       mochijson2:encode({struct, [{error, iolist_to_binary(Err)}]})}.
  
  api_relative_url(_APIVSN, UUID) when is_binary(UUID) ->
      iolist_to_binary([<<"/sessions/">>, UUID]).
  
  end_chunked_response(Socket) ->
      gen_tcp:close(Socket),
      ok.
  
  uri_to_binary(Uri) ->
      iolist_to_binary(ex_uri:encode(Uri)).
  
  valid_uri(Req) ->
      {struct, Data} = mochijson2:decode(Req:recv_body()),
      case proplists:get_value(<<"url">>, Data) of
          undefined ->
  