mirror of
https://github.com/apache/jclouds.git
synced 2025-02-07 18:49:52 +00:00
94b3cba6c2
Certain providers (e.g. Google Cloud Storage) place tokens that should be encoded in the request path (e.g. GET http://<host>/b/<bucket>/o/<object>) and expect them to be percent-encoded. In the above example a GET request for "foo/bar" should be translated to http://<host>/b/<bucket>/o/foo%2Fbar. Currently, there is no way to express this in jclouds, as the entire request path is encoded exactly once and there is no control over whether a request parameter should be handled specially. In the example above, "/" are not encoded in the path and the URL is submitted as "http://<host>/b/<bucket>/o/foo/bar", which may be wrong. This patch extends the annotation processor to support @Encoded for the individual parameters of the request. However, this means that the entire path is _NOT_ URL encoded. The caller *must* make sure that the appropriate parameters are encoded -- ones that are marked with the @Encoded annotation. Parameters not marked with the @Encoded annotation are URI encoded prior to being added to the path. This means that "/" characters will also be URI encoded in this case (i.e. "foo/bar" is turned into "foo%2Fbar"). For the Google Storage provider, we will annotate the parameters that are going to be pre-encoded (object names) and ensure the provider encodes them prior to calling the API (separate patch in jclouds-labs-google).