anchor.diff:  %% we must deliver a 302 if the browser asks for a dir
   %% without a trailing / in the HTTP req
   %% otherwise the relative urls in /dir/index.html will be broken.
  +%% Note: Here Path is always decoded, so we must encode it
   deliver_302(CliSock, _Req, Arg, Path) ->
       ?Debug("in redir 302 ",[]),
       H = get(outh),
       SC=get(sc),
       Scheme  = yaws:redirect_scheme(SC),
       Headers = Arg#arg.headers,
  -    DecPath = yaws_api:url_decode(Path),
  +    EncPath = yaws_api:url_encode(Path),
       RedirHost = yaws:redirect_host(SC, Headers#headers.host),
   
       %% QueryString must be added
       Loc = case Arg#arg.querydata of
  -              undefined -> ["Location: ", Scheme, RedirHost, DecPath, "\r\n"];
  -              [] -> ["Location: ", Scheme, RedirHost, DecPath, "\r\n"];
  -              Q -> ["Location: ", Scheme, RedirHost, DecPath, "?", Q, "\r\n"]
  +              undefined -> ["Location: ", Scheme, RedirHost, EncPath, "\r\n"];
  +              [] -> ["Location: ", Scheme, RedirHost, EncPath, "\r\n"];
  +              Q -> ["Location: ", Scheme, RedirHost, EncPath, "?", Q, "\r\n"]
             end,
       new_redir_h(H, Loc),
       deliver_accumulated(CliSock),
  
positive.code:     %% Here Code is 3xx
      ?Debug("in redir ~p", [Code]),
      H = get(outh),
      DecPath = safe_decode_path(Req#http_request.path),
      Loc = if
                Mode == append ->
                    NPath   = filename:join([URL#url.path ++ DecPath]),
                    LocPath = yaws_api:format_partial_url(URL#url{path=NPath},
                                                          get(sc)),
                    ["Location: ", LocPath, "\r\n"];
                true -> %% noappend
                    LocPath = yaws_api:format_partial_url(URL, get(sc)),
                    case yaws:split_at(DecPath, $?) of
                        {_, []} -> ["Location: ", LocPath, "\r\n"];
                        {_, Q}  -> ["Location: ", LocPath, "?", Q, "\r\n"]
                    end
            end,
      {DoClose, _Chunked} = yaws:dcc(Req, Arg#arg.headers),
      new_redir_h(H#outh{
                    connection = yaws:make_connection_close_header(DoClose),
  
negative.code: 
                      case {IsRev, IsRedirect} of
                          {_, {true, Redir}} ->
                              ARG1 = ARG#arg{server_path = DecPath,
                                             querydata   = QueryString},
                              deliver_redirect_map(CliSock, Req, ARG1, Redir, N);
                          {false, _} ->
                              %%'main' branch so to speak. Most requests
                              %% pass through here.
  