lib/shuck/server.rb in shuck-0.0.4 vs lib/shuck/server.rb in shuck-0.0.5
- old
+ new
@@ -45,16 +45,18 @@
response.body = XmlAdapter.error_no_such_bucket(bucket)
response['Content-Type'] = "application/xml"
end
else
object = elems[1,elems.size].join('/')
- io = @store.get_object(bucket,object)
- if io
+ real_obj = @store.get_object(bucket,object)
+ if real_obj
response.status = 200
response['Content-Type'] = "application/octet-stream"
- response.body = io
- response.chunked = true
+ response['Content-Length'] = real_obj.io.size
+ response['Etag'] = real_obj.md5
+ response.body = real_obj.io
+ puts real_obj.io.size
else
response.status = 404
response.body = ""
end
end
@@ -64,10 +66,11 @@
def do_PUT(request,response)
path = request.path
path_len = path.size
path_style_request = true
host = request["Host"]
+ puts host
bucket = nil
path_style_request = true
if host != @hostname
bucket = host.split(".")[0]
path_style_request = false
@@ -90,13 +93,15 @@
if path_style_request
if elems.size == 1
@store.create_bucket(bucket)
else
object = elems[1,elems.size].join('/')
- @store.store_object(bucket,object,request)
+ real_obj = @store.store_object(bucket,object,request)
+ response['Etag'] = real_obj.md5
end
else
- @store.store_object(bucket,path,request)
+ real_obj = @store.store_object(bucket,path,request)
+ response['Etag'] = real_obj.md5
end
end
response.status = 200
response.body = ""
response['Content-Type'] = "text/xml"