Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-02-02 20:22:04 +0300
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-02-02 20:22:04 +0300
commit752468d55bb167cfb7d327c660a62caa52dac792 (patch)
tree585b45cc5243e165017c40edd8b86d5d27a8ced2 /lib
parentdc390c5ac250a3dd7e03b950c96be18905d6e51b (diff)
parentea41d3607769b2b726a25d50ea23675bc5936227 (diff)
Merge branch 'git-raw-workhorse' into 'master'
Send raw Git blobs via gitlab-workhorse See merge request !2451
Diffstat (limited to 'lib')
-rw-r--r--lib/api/repositories.rb4
-rw-r--r--lib/gitlab/workhorse.rb21
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index d7c48639eba..c95d2d2001d 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -57,7 +57,7 @@ module API
not_found! "File" unless blob
content_type 'text/plain'
- present blob.data
+ header *Gitlab::Workhorse.send_git_blob(repo, blob)
end
# Get a raw blob contents by blob sha
@@ -83,7 +83,7 @@ module API
env['api.format'] = :txt
content_type blob.mime_type
- present blob.data
+ header *Gitlab::Workhorse.send_git_blob(repo, blob)
end
# Get a an archive of the repository
diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb
new file mode 100644
index 00000000000..a23120a4176
--- /dev/null
+++ b/lib/gitlab/workhorse.rb
@@ -0,0 +1,21 @@
+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