-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grape v1.4.0 fixes a memory leak that was present in v1.3.3 (ruby-grape/grape#2084). Full list of changes: * https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md * https://github.com/ruby-grape/grape/compare/v1.3.3..v1.4.0
- Loading branch information
Showing
5 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Update to Grape v1.4.0 | ||
merge_request: 36628 | ||
author: | ||
type: fixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters