Skip to content
Snippets Groups Projects
Commit 02afa679 authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Use only one header to send git blobs

parent 0197549d
No related branches found
No related tags found
1 merge request!2451Send raw Git blobs via gitlab-workhorse
Loading
@@ -6,8 +6,7 @@ class Projects::AvatarsController < Projects::ApplicationController
Loading
@@ -6,8 +6,7 @@ class Projects::AvatarsController < Projects::ApplicationController
@blob = repository.blob_at_branch('master', @project.avatar_in_git) @blob = repository.blob_at_branch('master', @project.avatar_in_git)
if @blob if @blob
headers['X-Content-Type-Options'] = 'nosniff' headers['X-Content-Type-Options'] = 'nosniff'
headers['Gitlab-Workhorse-Repo-Path'] = repository.path_to_repo headers.store(*Gitlab::Workhorse.send_git_blob(repository, @blob))
headers['Gitlab-Workhorse-Send-Blob'] = @blob.id
headers['Content-Disposition'] = 'inline' headers['Content-Disposition'] = 'inline'
render nothing: true, content_type: @blob.content_type render nothing: true, content_type: @blob.content_type
else else
Loading
Loading
Loading
@@ -15,8 +15,7 @@ class Projects::RawController < Projects::ApplicationController
Loading
@@ -15,8 +15,7 @@ class Projects::RawController < Projects::ApplicationController
if @blob.lfs_pointer? if @blob.lfs_pointer?
send_lfs_object send_lfs_object
else else
headers['Gitlab-Workhorse-Repo-Path'] = @repository.path_to_repo headers.store(*Gitlab::Workhorse.send_git_blob(@repository, @blob))
headers['Gitlab-Workhorse-Send-Blob'] = @blob.id
headers['Content-Disposition'] = 'inline' headers['Content-Disposition'] = 'inline'
render nothing: true, content_type: get_blob_type render nothing: true, content_type: get_blob_type
end end
Loading
Loading
Loading
@@ -57,8 +57,7 @@ module API
Loading
@@ -57,8 +57,7 @@ module API
not_found! "File" unless blob not_found! "File" unless blob
   
content_type 'text/plain' content_type 'text/plain'
header 'Gitlab-Workhorse-Repo-Path', repo.path_to_repo header *Gitlab::Workhorse.send_git_blob(repo, blob)
header 'Gitlab-Workhorse-Send-Blob', blob.id
end end
   
# Get a raw blob contents by blob sha # Get a raw blob contents by blob sha
Loading
@@ -84,8 +83,7 @@ module API
Loading
@@ -84,8 +83,7 @@ module API
env['api.format'] = :txt env['api.format'] = :txt
   
content_type blob.mime_type content_type blob.mime_type
header 'Gitlab-Workhorse-Repo-Path', repo.path_to_repo header *Gitlab::Workhorse.send_git_blob(repo, blob)
header 'Gitlab-Workhorse-Send-Blob', blob.id
end end
   
# Get a an archive of the repository # Get a an archive of the repository
Loading
Loading
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment