fastly / fastly-py

A Fastly API client for Python
https://pypi.org/project/fastly/
MIT License
77 stars 59 forks source link

kwarg passed to a URI Template needs URI quoting. #7

Closed cdent closed 1 year ago

cdent commented 11 years ago

If you provide a name for a Model, such as a Healthcheck that has a space in it, the created URI will fail with a 404 as the space has not been escaped to %20.

The naive fix is something like the following in models.py:

@@ -12,6 +12,9 @@ class Model(object):

     @classmethod
     def query(cls, conn, pattern, method, suffix='', body=None, **kwargs):
+        for key in kwargs:
+            value = quote(kwargs[key], safe='')
+            kwargs[key] = value

This isn't entirely explicit though as the overlap between self.attrs as source for body data and URI data isn't entirely clear.

cdent commented 11 years ago

This is a bit more complete, handles situations where a value is None (which won't encode). It is skipped:

        kwargs = {key: quote(value, safe='')
            for key, value in kwargs.iteritems()
            if value}
Integralist commented 1 year ago

Closing this issue now we've published v1.0.0 https://pypi.org/project/fastly/