lib/fakes3/server.rb in fakes3-0.1.6.1 vs lib/fakes3/server.rb in fakes3-0.1.7

- old
+ new

@@ -88,18 +88,34 @@ response.body = XmlAdapter.error_no_such_key(s_req.object) response['Content-Type'] = "application/xml" return end + if_none_match = request["If-None-Match"] + if if_none_match == "\"#{real_obj.md5}\"" or if_none_match == "*" + response.status = 304 + return + end + + if_modified_since = request["If-Modified-Since"] + if if_modified_since + time = Time.httpdate(if_modified_since) + if time >= Time.iso8601(real_obj.modified_date) + response.status = 304 + return + end + end + response.status = 200 response['Content-Type'] = real_obj.content_type stat = File::Stat.new(real_obj.io.path) response['Last-Modified'] = Time.iso8601(real_obj.modified_date).httpdate() response.header['ETag'] = "\"#{real_obj.md5}\"" response['Accept-Ranges'] = "bytes" response['Last-Ranges'] = "bytes" + response['Access-Control-Allow-Origin'] = '*' real_obj.custom_metadata.each do |header, value| response.header['x-amz-meta-' + header] = value end @@ -139,10 +155,11 @@ s_req = normalize_request(request) response.status = 200 response.body = "" response['Content-Type'] = "text/xml" + response['Access-Control-Allow-Origin'] = '*' case s_req.type when Request::COPY object = @store.copy_object(s_req.src_bucket,s_req.src_object,s_req.bucket,s_req.object,request) response.body = XmlAdapter.copy_object_result(object) @@ -195,11 +212,11 @@ </PostResponse> eos end end response['Content-Type'] = 'text/xml' - response['Access-Control-Allow-Origin']='*' + response['Access-Control-Allow-Origin'] = '*' end def do_DELETE(request,response) s_req = normalize_request(request) @@ -215,10 +232,13 @@ response.body = "" end def do_OPTIONS(request, response) super - response["Access-Control-Allow-Origin"]="*" + response["Access-Control-Allow-Origin"] = "*" + response["Access-Control-Allow-Methods"] = "HEAD, GET, PUT, POST" + response["Access-Control-Allow-Headers"] = "accept, content-type" + response["Access-Control-Expose-Headers"] = "ETag, x-amz-meta-custom-header" end private def normalize_delete(webrick_req,s_req)