anchor.diff:                   try_host_binding([], ["bar","foo"], 1234, ["x","y","z"], 0, RD)).
   
   dispatch_test() ->
  -    RD = testing,
  +    RD = wrq:create('GET', http, {1,1}, "testing", mochiweb_headers:from_list([])),
       TrueFun = fun(_) -> true end,
       FalseFun = fun(_) -> false end,
   
  
positive.code:     ?assertEqual(["foo","bar","baz"], split_host("foo.bar.baz")).
  
  split_host_port_test() ->
      ?assertEqual({[], 80}, split_host_port("")),
      ?assertEqual({["foo","bar","baz"], 80},
                   split_host_port("foo.bar.baz:80")),
      ?assertEqual({["foo","bar","baz"], 1234},
                   split_host_port("foo.bar.baz:1234")).
  
  %% port binding
  bind_port_simple_match_test() ->
  
negative.code:                      true -> 1;
                       _ -> 0
                   end,
      {Host, Port} = split_host_port(HostAsString, wrq:scheme(RD)),
      try_host_binding(DispatchList, Host, Port, Path, ExtraDepth, RD).
  
  split_host_port(HostAsString, Scheme) ->
      case string:tokens(HostAsString, ":") of
          [HostPart, PortPart] ->
              {split_host(HostPart), list_to_integer(PortPart)};
          [HostPart] ->
              {split_host(HostPart), default_port(Scheme)};
          [] ->
              %% no host header
              {[], default_port(Scheme)}
      end.
  
  split_host(HostAsString) ->
      string:tokens(HostAsString, ".").
  
  default_port(http) -> 80;
  default_port(https) -> 443.
  
  %% @type matchterm() = hostmatchterm() | pathmatchterm().
  % The dispatch configuration is a list of these terms, and the
  