anchor.diff:  -endif.
   
   -type subresource() :: {string(), string()}.
  +-type query_params() :: [{string(), string()}].
   -type subresources() :: [subresource()].
   
   %% @doc Function to rewrite headers prior to processing by webmachine.
  
positive.code: 
  %% @doc Format a bucket operation query string to conform the the
  %% rewrite rules.
  -spec format_bucket_qs(string(), subresources()) -> string().
  format_bucket_qs([], []) ->
      "/objects";
  format_bucket_qs("delete", []) ->
      "/objects";
  format_bucket_qs(QS, []) ->
      ["/objects?", QS];
  format_bucket_qs(_QS, SubResources) ->
      format_subresources(SubResources).
  
  %% @doc Format an object operation query string to conform the the
  %% rewrite rules.
  -spec format_object_qs(subresources()) -> string().
  format_object_qs(SubResources) ->
      UploadId = proplists:get_value("uploadId", SubResources, []),
      PartNum = proplists:get_value("partNumber", SubResources, []),
      format_object_qs(SubResources, UploadId, PartNum).
  
negative.code: format_subresources([{Key, []} | _]) ->
      ["/", Key].
  
  %% @doc Format a proplist of query parameters into a string
  -spec format_query_params(query_params()) -> string().
  format_query_params([]) ->
      [];
  format_query_params(QueryParams) ->
      format_query_params(QueryParams, []).
  
  %% @doc Format a proplist of query parameters into a string
  -spec format_query_params(query_params(), list()) -> string().
  format_query_params([], QS) ->
      ["?", QS];
  format_query_params([{Key, []} | RestParams], []) ->
      format_query_params(RestParams, [Key]);
  format_query_params([{Key, []} | RestParams], QS) ->
      format_query_params(RestParams, [[Key, "&"] | QS]);
  format_query_params([{Key, Value} | RestParams], []) ->
      format_query_params(RestParams, [Key, "=", Value]);
  format_query_params([{Key, Value} | RestParams], QS) ->
      format_query_params(RestParams, [[Key, "=", Value, "&"] | QS]).
  
  %% @doc Parse the valid subresources from the raw path.
  -spec get_subresources(string()) -> {subresources(), query_params()}.
  get_subresources(QueryString) ->
      lists:partition(fun valid_subresource/1, mochiweb_util:parse_qs(QueryString)).
  
  %% @doc Determine if a query parameter key is a valid S3 subresource
  -spec valid_subresource(subresource()) -> boolean().
  