Commit 02afa679 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Use only one header to send git blobs

parent 0197549d
......@@ -6,8 +6,7 @@ class Projects::AvatarsController < Projects::ApplicationController
@blob = repository.blob_at_branch('master', @project.avatar_in_git)
if @blob
headers['X-Content-Type-Options'] = 'nosniff'
headers['Gitlab-Workhorse-Repo-Path'] = repository.path_to_repo
headers['Gitlab-Workhorse-Send-Blob'] = @blob.id
headers.store(*Gitlab::Workhorse.send_git_blob(repository, @blob))
headers['Content-Disposition'] = 'inline'
render nothing: true, content_type: @blob.content_type
else
......
......@@ -15,8 +15,7 @@ class Projects::RawController < Projects::ApplicationController
if @blob.lfs_pointer?
send_lfs_object
else
headers['Gitlab-Workhorse-Repo-Path'] = @repository.path_to_repo
headers['Gitlab-Workhorse-Send-Blob'] = @blob.id
headers.store(*Gitlab::Workhorse.send_git_blob(@repository, @blob))
headers['Content-Disposition'] = 'inline'
render nothing: true, content_type: get_blob_type
end
......
......@@ -57,8 +57,7 @@ module API
not_found! "File" unless blob
content_type 'text/plain'
header 'Gitlab-Workhorse-Repo-Path', repo.path_to_repo
header 'Gitlab-Workhorse-Send-Blob', blob.id
header *Gitlab::Workhorse.send_git_blob(repo, blob)
end
# Get a raw blob contents by blob sha
......@@ -84,8 +83,7 @@ module API
env['api.format'] = :txt
content_type blob.mime_type
header 'Gitlab-Workhorse-Repo-Path', repo.path_to_repo
header 'Gitlab-Workhorse-Send-Blob', blob.id
header *Gitlab::Workhorse.send_git_blob(repo, blob)
end
# Get a an archive of the repository
......
require 'base64'
require 'json'
module Gitlab
class Workhorse
class << self
def send_git_blob(repository, blob)
params_hash = {
'RepoPath' => repository.path_to_repo,
'BlobId' => blob.id,
}
params = Base64.urlsafe_encode64(JSON.dump(params_hash))
[
'Gitlab-Workhorse-Send-Data',
"git-blob:#{params}",
]
end
end
end
end
\ No newline at end of file
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