Skip to content

Instantly share code, notes, and snippets.

@HugoKuo
Created June 4, 2019 03:37
Show Gist options
  • Save HugoKuo/d2a9b535a19b9da0338dd0ad60c9dc5b to your computer and use it in GitHub Desktop.
Save HugoKuo/d2a9b535a19b9da0338dd0ad60c9dc5b to your computer and use it in GitHub Desktop.
if-none-match cases
(python-swiftclient) Hugos-2016-MacBook-Pro:swift-source-files hugo$ swift --debug stat match-test 2.txt -H "if-none-match: c5f8ea22debac96d25c4c105d2af1ff6"
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.22.92
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.22.92:80 "GET /auth/v1.0 HTTP/1.1" 200 0
DEBUG:swiftclient:REQ: curl -i http://192.168.22.92/auth/v1.0 -X GET
DEBUG:swiftclient:RESP STATUS: 200 OK
DEBUG:swiftclient:RESP HEADERS: {u'Content-Length': u'0', u'Set-Cookie': u'X-Auth-Token=AUTH_tkb6c56e03bde5487993d83a6ba4a50727; Path=/', u'X-Trans-Id': u'tx420b14ff06a24416bca8f-005cf5e731', u'X-Auth-Token': u'AUTH_tkb6c56e03bde5487993d83a6ba4a50727', u'X-Storage-Token': u'AUTH_tkb6c56e03bde5487993d83a6ba4a50727', u'Date': u'Tue, 04 Jun 2019 03:36:17 GMT', u'X-Storage-Url': u'http://192.168.22.92/v1/AUTH_demo', u'Content-Type': u'text/plain; charset=UTF-8', u'X-Openstack-Request-Id': u'tx420b14ff06a24416bca8f-005cf5e731'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.22.92
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.22.92:80 "HEAD /v1/AUTH_demo/match-test/2.txt HTTP/1.1" 304 0
INFO:swiftclient:REQ: curl -i http://192.168.22.92/v1/AUTH_demo/match-test/2.txt -I -H "If-None-Match: c5f8ea22debac96d25c4c105d2af1ff6" -H "X-Auth-Token: AUTH_tkb6c56e03bde5487993d83a6ba4a50727"
INFO:swiftclient:RESP STATUS: 304 Not Modified
INFO:swiftclient:RESP HEADERS: {u'Content-Length': u'0', u'X-Object-Meta-Mtime': u'1532925548.523582', u'Accept-Ranges': u'bytes', u'Last-Modified': u'Tue, 04 Jun 2019 03:24:30 GMT', u'Etag': u'c5f8ea22debac96d25c4c105d2af1ff6', u'X-Timestamp': u'1559618669.34945', u'X-Trans-Id': u'tx8411b441073c464d98a09-005cf5e731', u'Date': u'Tue, 04 Jun 2019 03:36:17 GMT', u'Content-Type': u'text/plain', u'X-Openstack-Request-Id': u'tx8411b441073c464d98a09-005cf5e731'}
ERROR:swiftclient.service:Object HEAD failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 304 Not Modified
Traceback (most recent call last):
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/service.py", line 604, in _stat_object
items, headers = stat_object(conn, options, container, obj)
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/command_helpers.py", line 146, in stat_object
headers = conn.head_object(container, obj, headers=req_headers)
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/client.py", line 1826, in head_object
query_string=query_string)
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/client.py", line 1722, in _retry
service_token=self.service_token, **kwargs)
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/client.py", line 1252, in head_object
raise ClientException.from_response(resp, 'Object HEAD failed', body)
ClientException: Object HEAD failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 304 Not Modified
Object HEAD failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 304 Not Modified
Failed Transaction ID: tx8411b441073c464d98a09-005cf5e731
(python-swiftclient) Hugos-2016-MacBook-Pro:swift-source-files hugo$ swift upload match-test 2.txt -H "if-none-match: *"
Object PUT failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 412 Precondition Failed [first 60 chars of response] <html><h1>Precondition Failed</h1><p>A precondition for this
(python-swiftclient) Hugos-2016-MacBook-Pro:swift-source-files hugo$ swift --debug upload match-test 2.txt -H "if-none-match: *"
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.22.92
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.22.92:80 "GET /auth/v1.0 HTTP/1.1" 200 0
DEBUG:swiftclient:REQ: curl -i http://192.168.22.92/auth/v1.0 -X GET
DEBUG:swiftclient:RESP STATUS: 200 OK
DEBUG:swiftclient:RESP HEADERS: {u'Content-Length': u'0', u'Set-Cookie': u'X-Auth-Token=AUTH_tkb6c56e03bde5487993d83a6ba4a50727; Path=/', u'X-Trans-Id': u'tx7c8f41a908d94a849d08b-005cf5e559', u'X-Auth-Token': u'AUTH_tkb6c56e03bde5487993d83a6ba4a50727', u'X-Storage-Token': u'AUTH_tkb6c56e03bde5487993d83a6ba4a50727', u'Date': u'Tue, 04 Jun 2019 03:28:25 GMT', u'X-Storage-Url': u'http://192.168.22.92/v1/AUTH_demo', u'Content-Type': u'text/plain; charset=UTF-8', u'X-Openstack-Request-Id': u'tx7c8f41a908d94a849d08b-005cf5e559'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.22.92
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.22.92:80 "PUT /v1/AUTH_demo/match-test HTTP/1.1" 202 76
DEBUG:swiftclient:REQ: curl -i http://192.168.22.92/v1/AUTH_demo/match-test -X PUT -H "Content-Length: 0" -H "X-Auth-Token: AUTH_tkb6c56e03bde5487993d83a6ba4a50727"
DEBUG:swiftclient:RESP STATUS: 202 Accepted
DEBUG:swiftclient:RESP HEADERS: {u'Date': u'Tue, 04 Jun 2019 03:28:25 GMT', u'Content-Length': u'76', u'Content-Type': u'text/html; charset=UTF-8', u'X-Openstack-Request-Id': u'tx067a068b18f9485e8f083-005cf5e559', u'X-Trans-Id': u'tx067a068b18f9485e8f083-005cf5e559'}
DEBUG:swiftclient:RESP BODY: <html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.22.92
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.22.92:80 "GET /auth/v1.0 HTTP/1.1" 200 0
DEBUG:swiftclient:REQ: curl -i http://192.168.22.92/auth/v1.0 -X GET
DEBUG:swiftclient:RESP STATUS: 200 OK
DEBUG:swiftclient:RESP HEADERS: {u'Content-Length': u'0', u'Set-Cookie': u'X-Auth-Token=AUTH_tkb6c56e03bde5487993d83a6ba4a50727; Path=/', u'X-Trans-Id': u'tx0a27e10194d740f29f939-005cf5e559', u'X-Auth-Token': u'AUTH_tkb6c56e03bde5487993d83a6ba4a50727', u'X-Storage-Token': u'AUTH_tkb6c56e03bde5487993d83a6ba4a50727', u'Date': u'Tue, 04 Jun 2019 03:28:25 GMT', u'X-Storage-Url': u'http://192.168.22.92/v1/AUTH_demo', u'Content-Type': u'text/plain; charset=UTF-8', u'X-Openstack-Request-Id': u'tx0a27e10194d740f29f939-005cf5e559'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.22.92
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.22.92:80 "HEAD /v1/AUTH_demo/match-test/2.txt HTTP/1.1" 200 0
DEBUG:swiftclient:REQ: curl -i http://192.168.22.92/v1/AUTH_demo/match-test/2.txt -I -H "X-Auth-Token: AUTH_tkb6c56e03bde5487993d83a6ba4a50727"
DEBUG:swiftclient:RESP STATUS: 200 OK
DEBUG:swiftclient:RESP HEADERS: {u'Content-Length': u'1836', u'X-Object-Meta-Mtime': u'1532925548.523582', u'Accept-Ranges': u'bytes', u'Last-Modified': u'Tue, 04 Jun 2019 03:24:30 GMT', u'Etag': u'c5f8ea22debac96d25c4c105d2af1ff6', u'X-Timestamp': u'1559618669.34945', u'X-Trans-Id': u'tx065aca3c27fa42f4a13c3-005cf5e559', u'Date': u'Tue, 04 Jun 2019 03:28:25 GMT', u'Content-Type': u'text/plain', u'X-Openstack-Request-Id': u'tx065aca3c27fa42f4a13c3-005cf5e559'}
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.22.92:80 "PUT /v1/AUTH_demo/match-test/2.txt HTTP/1.1" 412 92
INFO:swiftclient:REQ: curl -i http://192.168.22.92/v1/AUTH_demo/match-test/2.txt -X PUT -H "If-None-Match: *" -H "Content-Length: 1836" -H "x-object-meta-mtime: 1532925548.523582" -H "X-Auth-Token: AUTH_tkb6c56e03bde5487993d83a6ba4a50727"
INFO:swiftclient:RESP STATUS: 412 Precondition Failed
INFO:swiftclient:RESP HEADERS: {u'Date': u'Tue, 04 Jun 2019 03:28:25 GMT', u'Content-Length': u'92', u'Content-Type': u'text/html; charset=UTF-8', u'X-Openstack-Request-Id': u'txa0b3f7dd736c4c8a91c32-005cf5e559', u'X-Trans-Id': u'txa0b3f7dd736c4c8a91c32-005cf5e559'}
INFO:swiftclient:RESP BODY: <html><h1>Precondition Failed</h1><p>A precondition for this request was not met.</p></html>
ERROR:swiftclient.service:Object PUT failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 412 Precondition Failed [first 60 chars of response] <html><h1>Precondition Failed</h1><p>A precondition for this
Traceback (most recent call last):
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/service.py", line 2249, in _upload_object_job
response_dict=obr
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/client.py", line 1878, in put_object
response_dict=response_dict)
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/client.py", line 1722, in _retry
service_token=self.service_token, **kwargs)
File "/Users/hugo/Documents/virtual-env/python-swiftclient/lib/python2.7/site-packages/swiftclient/client.py", line 1366, in put_object
raise ClientException.from_response(resp, 'Object PUT failed', body)
ClientException: Object PUT failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 412 Precondition Failed [first 60 chars of response] <html><h1>Precondition Failed</h1><p>A precondition for this
Object PUT failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 412 Precondition Failed [first 60 chars of response] <html><h1>Precondition Failed</h1><p>A precondition for this
(python-swiftclient) Hugos-2016-MacBook-Pro:swift-source-files hugo$ swift stat match-test nothing -H "if-none-match: 123"
Object HEAD failed: http://192.168.22.92/v1/AUTH_demo/match-test/nothing 404 Not Found
Failed Transaction ID: txfc9f309d8be5459f8b9fa-005cf5e41f
(python-swiftclient) Hugos-2016-MacBook-Pro:swift-source-files hugo$ swift upload match-test 2.txt -H "if-none-match: 123"
Object PUT failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 400 Bad Request If-None-Match only supports *
(python-swiftclient) Hugos-2016-MacBook-Pro:swift-source-files hugo$ swift upload match-test 2.txt -H "if-none-match: '123'"
Object PUT failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 400 Bad Request If-None-Match only supports *
(python-swiftclient) Hugos-2016-MacBook-Pro:swift-source-files hugo$ swift upload match-test 2.txt -H "if-none-match: '*'"
Object PUT failed: http://192.168.22.92/v1/AUTH_demo/match-test/2.txt 400 Bad Request If-None-Match only supports *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment