Commit 81e88815 authored by Lucas Carvalho's avatar Lucas Carvalho

Using PUT instead of POST and fixed the status.

parent 644db70b
...@@ -75,14 +75,14 @@ class NetworkcacheClient(object): ...@@ -75,14 +75,14 @@ class NetworkcacheClient(object):
shacache_connection = httplib.HTTPConnection(self.shacache_host, shacache_connection = httplib.HTTPConnection(self.shacache_host,
self.shacache_port) self.shacache_port)
try: try:
shacache_connection.request('POST', path, file_content, shacache_connection.request('PUT', path, file_content,
self.shacache_header_dict) self.shacache_header_dict)
result = shacache_connection.getresponse() result = shacache_connection.getresponse()
data = result.read() data = result.read()
finally: finally:
shacache_connection.close() shacache_connection.close()
if result.status != 200: if result.status != 201:
raise UploadError('Failed to upload the file to SHACACHE Server.' \ raise UploadError('Failed to upload the file to SHACACHE Server.' \
'URL: %s. Response code: %s. Response data: %s' % \ 'URL: %s. Response code: %s. Response data: %s' % \
(self.shacache_host, result.status, data)) (self.shacache_host, result.status, data))
...@@ -106,14 +106,14 @@ class NetworkcacheClient(object): ...@@ -106,14 +106,14 @@ class NetworkcacheClient(object):
shadir_connection = httplib.HTTPConnection(self.shadir_host, shadir_connection = httplib.HTTPConnection(self.shadir_host,
self.shadir_port) self.shadir_port)
try: try:
shadir_connection.request('POST', path, json.dumps(data), shadir_connection.request('PUT', path, json.dumps(data),
self.shadir_header_dict) self.shadir_header_dict)
result = shadir_connection.getresponse() result = shadir_connection.getresponse()
data = result.read() data = result.read()
finally: finally:
shadir_connection.close() shadir_connection.close()
if result.status != 200: if result.status != 201:
raise UploadError('Failed to upload data to SHADIR Server.' \ raise UploadError('Failed to upload data to SHADIR Server.' \
'URL: %s. Response code: %s. Response data: %s' % \ 'URL: %s. Response code: %s. Response data: %s' % \
(self.shacache_host, result.status, data)) (self.shacache_host, result.status, data))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment