libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Metzler (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LIBCLOUD-552) CloudFiles CURL Request uses -X HEAD instead of --head or -I
Date Fri, 16 May 2014 11:02:12 GMT

    [ https://issues.apache.org/jira/browse/LIBCLOUD-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13999312#comment-13999312
] 

Brian Metzler commented on LIBCLOUD-552:
----------------------------------------

This can be easily produced by attempting to download a file, from Cloud Files, where there
is a Space in the Object name.  When libcloud attempts to verify the Metadata on the object,
before downloading it, it fails due to the head request issue.

When attempting to do this directly through Rackspace's API, there is no issue with the '--head'
flag, but when you attempt to use the '-X HEAD' flag, curl 
attempts to downloading the full file.

This was originally reported to me via https://community.rackspace.com/developers/f/7/p/3752/9330

Here is an example to reproduce it with the latest version 0.14.1 available.

>>> from libcloud.storage.providers import get_driver
>>> from libcloud.storage.types import Provider
>>> 
>>> USERNAME = 'USERNAMEHERE'
>>> API_KEY = 'APIKEYHERE'
>>> CONTAINERNAME='CONTAINERNAMEHERE'
>>> DOWNLOADPATH='DOWNLOADPATHHERE'  #/home/user/Downloads/
>>> cls = get_driver(Provider.CLOUDFILES_US)
>>> driver = cls(USERNAME, API_KEY)
>>> container=driver.get_container(CONTAINERNAME)
>>> objects=container.list_objects()
>>> for obj in enumerate(objects):
...     print obj
...
(0, <Object: name=This is a test.txt, size=750751, hash=cefd3204913d3817edaf67cca76dcb0d,
provider=CloudFiles (US) ...>)
(1, <Object: name=Thisisatest.txt, size=750751, hash=cefd3204913d3817edaf67cca76dcb0d,
provider=CloudFiles (US) ...>)
>>> object=container.get_object("Thisisatest.txt")
>>> object.download(DOWNLOADPATHHERE,overwrite_existing=True)
True
>>> object=container.get_object("This is a test.txt")
>>> object.download(DOWNLOADPATH,overwrite_existing=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/libcloud/storage/base.py", line 100, in download
    delete_on_failure)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/storage/drivers/cloudfiles.py", line
372, in download_object
    success_status_code=httplib.OK)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/storage/base.py", line 502, in _get_object
    driver=self)
libcloud.common.types.LibcloudError: <LibcloudError in <libcloud.storage.drivers.cloudfiles.CloudFilesUSStorageDriver
object at 0x3037390> 'Unexpected status code: 400'>













> CloudFiles CURL Request uses -X HEAD instead of --head or -I
> ------------------------------------------------------------
>
>                 Key: LIBCLOUD-552
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-552
>             Project: Libcloud
>          Issue Type: Improvement
>          Components: Storage
>    Affects Versions: 0.14.0-beta3
>         Environment: Ubuntu 12.04.4 LTS
> curl 7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23
librtmp/2.3
> Python 2.7.3 and Python 3.2.3
>            Reporter: Brian Metzler
>            Priority: Critical
>         Attachments: debug.log
>
>
> When running driver.container.download_object(), it attempts to get the metadata of the
object by using 'curl -X HEAD', instead of 'curl -I' or 'curl --head'.  curl does not properly
handle HEAD requests with -X HEAD, as it still attempts to download the full file.
> Just turn on debugging, and check out the time it takes for a standard curl -I versus
curl -X HEAD.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message