Lispython / human_curl

Simple Human wrapper for cURL library
http://h.wrttn.me/human_curl
Other
205 stars 43 forks source link

fix send files list as list #32

Closed nwlunatic closed 10 years ago

nwlunatic commented 10 years ago

comment for make_curl_post_files(data): says """Convert parameters dict, list or tuple to cURL style tuple""" but list actually call's an error: raise ValueError("%s argument must be list, tuple or dict, not %s" % ("make_curl_post_files", type(data)))

Also in agreed with this pull request https://github.com/Lispython/human_curl/pull/14:

due to this code

class Request(object):
    def __init___(self, ...):
        ...
        # String, dict, tuple, list
        if isinstance(data, (StringTypes, NoneType)):
            self._data = data
        else:
            self._data = data_wrapper(data)

def data_wrapper(data):
    """Convert data to list and returns
    """
    ...

 def build_opener(self, url, opener=None):
     ...
        if self._files is not None:
                post_params = self._files
                if isinstance(self._data, (TupleType, DictType)):
                    post_params.extend(data_wrapper(self._data))
                opener.setopt(opener.HTTPPOST, post_params)

so we will never get to post_params.extend(data_wrapper(self._data)) if we are trying to send some files, because data is going to be wrapped in list in Request constructor.

Lispython commented 10 years ago

Thanks!