Class: Gitlab::Middleware::Multipart

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/middleware/multipart.rb

Defined Under Namespace

Classes: Handler

Constant Summary collapse

RACK_ENV_KEY =
'HTTP_GITLAB_WORKHORSE_MULTIPART_FIELDS'
JWT_PARAM_SUFFIX =
'.gitlab-workhorse-upload'
JWT_PARAM_FIXED_KEY =
'upload'
REWRITTEN_FIELD_NAME_MAX_LENGTH =
10000

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Multipart

Returns a new instance of Multipart.


167
168
169
# File 'lib/gitlab/middleware/multipart.rb', line 167

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object


171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/gitlab/middleware/multipart.rb', line 171

def call(env)
  encoded_message = env.delete(RACK_ENV_KEY)
  return @app.call(env) if encoded_message.blank?

  message = ::Gitlab::Workhorse.decode_jwt_with_issuer(encoded_message)[0]

  ::Gitlab::Middleware::Multipart::Handler.new(env, message).with_open_files do
    @app.call(env)
  end
rescue UploadedFile::InvalidPathError, ApolloUploadServer::GraphQLDataBuilder::OutOfBounds => e
  [400, { 'Content-Type' => 'text/plain' }, [e.message]]
end