diff --git a/lib/remote_storage/rest_provider.rb b/lib/remote_storage/rest_provider.rb index f50042d..7447c53 100644 --- a/lib/remote_storage/rest_provider.rb +++ b/lib/remote_storage/rest_provider.rb @@ -410,7 +410,9 @@ module RemoteStorage def do_get_request(url, &block) deal_with_unauthorized_requests do - RestClient.get(url, default_headers, &block) + headers = { } + headers["Range"] = server.env["HTTP_RANGE"] if server.env["HTTP_RANGE"] + RestClient.get(url, default_headers.merge(headers), &block) end end diff --git a/spec/swift/app_spec.rb b/spec/swift/app_spec.rb index eff8bd9..9871b4b 100644 --- a/spec/swift/app_spec.rb +++ b/spec/swift/app_spec.rb @@ -16,12 +16,20 @@ describe "Swift provider" do stub_request(:put, "#{container_url_for("phil")}/food/aguacate"). with(body: "aye"). to_return(status: 200, headers: { etag: "0915etag", last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) + stub_request(:put, "#{container_url_for("phil")}/public/shares/example.jpg"). + to_return(status: 200, headers: { etag: '"0817etag"', content_type: "image/jpeg", last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) + stub_request(:put, "#{container_url_for("phil")}/public/shares/example_partial.jpg"). + to_return(status: 200, headers: { etag: '"0817etag"', content_type: "image/jpeg", last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) stub_request(:head, "#{container_url_for("phil")}/food/aguacate"). to_return(status: 200, headers: { last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) stub_request(:get, "#{container_url_for("phil")}/food/aguacate"). to_return(status: 200, body: "rootbody", headers: { etag: "0817etag", content_type: "text/plain; charset=utf-8" }) stub_request(:delete, "#{container_url_for("phil")}/food/aguacate"). to_return(status: 200, headers: { etag: "0815etag" }) + stub_request(:get, "#{container_url_for("phil")}/public/shares/example.jpg"). + to_return(status: 200, body: "", headers: { etag: '"0817etag"', content_type: "image/jpeg" }) + stub_request(:get, "#{container_url_for("phil")}/public/shares/example_partial.jpg"). + to_return(status: 206, body: "", headers: { etag: '"0817etag"', content_type: "image/jpeg", content_range: "bytes 0-16/128" }) # Write new content to check the metadata in Redis stub_request(:put, "#{container_url_for("phil")}/food/banano").