anchor.diff:  %% Helpers
   %%====================================================================
   
  +%% @doc Create encoded HTTP URI suffix corresponding to the original key
  +build_original_path_info(hoststyle, CSBucket, CSKey, RootHost) ->
  +    Encoded = mochiweb_util:quote_plus(unicode:characters_to_list(CSKey)),
  +    Host = lists:flatten([binary_to_list(CSBucket), $. , RootHost]),
  +    {Encoded, Host};
  +build_original_path_info(pathstyle, CSBucket, CSKey, RootHost) ->
  +    Encoded0 = mochiweb_util:quote_plus(unicode:characters_to_list(CSKey)),
  +    Encoded = lists:flatten([$/, unicode:characters_to_list(CSBucket), $/, Encoded0]),
  +    {Encoded, RootHost}.
  +
   base_host() ->
       oneof(["s3.amazonaws.com", "riakcs.net", "snarf", "hah-hah", ""]).
   
  
positive.code:         [
           {timeout, ?TESTING_TIME*2,
            ?_assertEqual(true, quickcheck(eqc:testing_time(?TESTING_TIME,
                                                            ?QC_OUT(prop_s3_rewrite()))))},
           {timeout, ?TESTING_TIME*2,
            ?_assertEqual(true, quickcheck(eqc:testing_time(?TESTING_TIME,
                                                            ?QC_OUT(prop_extract_bucket_from_host()))))
  
negative.code: 
  %% @doc This test verifies that the key for object manifest is exactly same as
  %% the key before URL encoding. This is also a regression test of riak_cs#1040.
  prop_s3_rewrite(Style) ->
      RewriteModule = riak_cs_s3_rewrite,
      RootHost = "example.com",
      ok = application:set_env(riak_cs, cs_root_host, RootHost),
      DispatchTable = riak_cs_web:object_api_dispatch_table(),
      ?FORALL({CSBucket, CSKey, Verb, Scheme, Version},
              {riak_cs_gen:bucket(), riak_cs_gen:file_name(),
               riak_cs_gen:http_verb(), riak_cs_gen:http_scheme(),
               riak_cs_gen:http_version()},
              begin
                  {Encoded, Host} = build_original_path_info(Style, CSBucket, CSKey, RootHost),
                  Headers0 = riak_cs_s3_rewrite_test:headers([{"host", Host}]),
                  %% And create double-quoted Path to make wm dispatch
                  {Headers, Path} = RewriteModule:rewrite(Verb, Scheme, Version, Headers0, Encoded),
  
                  %% Let webmachine dispatcher create the #wm_reqdata to
                  %% make `riak_cs_wm_utils:extract_key/2' work,
                  %% Imitating webmachine dispatcher like CS.
                  RD0 = wrq:create(Verb, Scheme, Version, Encoded, Headers),
                  {_Mod, _ModOpts, HostTokens, Port, PathTokens, Bindings,
                   AppRoot, StringPath} = webmachine_dispatcher:dispatch(Host, Path,
                                                                         DispatchTable,
  