Commit 954897d3 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'sh-update-grape-1.4.0' into 'master'

Update to Grape v1.4.0

See merge request gitlab-org/gitlab!36628
parents 957212b5 94e343e3
......@@ -81,7 +81,9 @@ gem 'gitlab_omniauth-ldap', '~> 2.1.1', require: 'omniauth-ldap'
gem 'net-ldap'
# API
gem 'grape', '~> 1.3.3'
# Locked at Grape v1.4.0 until https://github.com/ruby-grape/grape/pull/2088 is merged
# Remove config/initializers/grape_patch.rb
gem 'grape', '= 1.4.0'
gem 'grape-entity', '~> 0.7.1'
gem 'rack-cors', '~> 1.0.6', require: 'rack/cors'
......
......@@ -453,7 +453,7 @@ GEM
signet (~> 0.14)
gpgme (2.0.20)
mini_portile2 (~> 2.3)
grape (1.3.3)
grape (1.4.0)
activesupport
builder
dry-types (>= 1.1)
......@@ -1269,7 +1269,7 @@ DEPENDENCIES
google-api-client (~> 0.33)
google-protobuf (~> 3.8.0)
gpgme (~> 2.0.19)
grape (~> 1.3.3)
grape (= 1.4.0)
grape-entity (~> 0.7.1)
grape-path-helpers (~> 1.3)
grape_logging (~> 1.7)
......
---
title: Update to Grape v1.4.0
merge_request: 36628
author:
type: fixed
# frozen_string_literal: true
# Monkey patch for Grape v1.4.0: https://github.com/ruby-grape/grape/pull/2088
require 'grape'
# rubocop:disable Gitlab/ModuleWithInstanceVariables
module Grape
module DSL
module InsideRoute
def stream(value = nil)
return if value.nil? && @stream.nil?
header 'Content-Length', nil
header 'Transfer-Encoding', nil
header 'Cache-Control', 'no-cache' # Skips ETag generation (reading the response up front)
if value.is_a?(String)
file_body = Grape::ServeStream::FileBody.new(value)
@stream = Grape::ServeStream::StreamResponse.new(file_body)
elsif value.respond_to?(:each)
@stream = Grape::ServeStream::StreamResponse.new(value)
elsif !value.is_a?(NilClass)
raise ArgumentError, 'Stream object must respond to :each.'
else
@stream
end
end
end
end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
......@@ -504,7 +504,7 @@ module API
header['X-Sendfile'] = path
body
else
file path
sendfile path
end
end
......
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