gitlab-grack 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2043f542b17f7cfb055ff210da481b0d2396e285
4
- data.tar.gz: dbe633ec5179035e0d9f99c90ab4df8af0d6c6c1
3
+ metadata.gz: 23b1962af9b51c2805167e6b627d5357dcee1752
4
+ data.tar.gz: 74d0879a706bc19457bc6fae3bbf5dc0c7bdc135
5
5
  SHA512:
6
- metadata.gz: d64c06b4125048c4bb68136d9dddf4c972ec9a1080f4492d2dafc3d1e1f965cbba40071d2c2f18a434ae824121d006ff5e73ffc936955dbde6fd8a9504e4bf94
7
- data.tar.gz: 86032ba1a3c5ed1dba412d029e3b20076f79ceb62f6370012a6afbe87c02d0c2c7871ed4e8713559072457fb0fe2540e96e93ba5bf2c6cb6a4a9b623e2aa5ee3
6
+ metadata.gz: 3b52af3a8f9be5abaa0f7a0513c127c67a2900ba315a431bb2b2d51dbfd4fd7f10a42a95d71b1d954b5862e34adb28619a3b2831c271bbeca713fc217e9005b3
7
+ data.tar.gz: bc0cabeec601326501c9c80c56dba59cd19eb4bf39cf905918426d67a2b65625cb77a9a983fb8beb2b3d1b3936c66401c6f69663468c9b9146515875f1fa16df
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  coverage/
2
2
  pkg/
3
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ env:
3
+ - TRAVIS=true
4
+ branches:
5
+ only:
6
+ - 'master'
7
+ rvm:
8
+ - 1.9.3-p327
9
+ - 2.0.0
10
+ before_script:
11
+ - "bundle install"
12
+ - "git submodule init"
13
+ - "git submodule update"
14
+ script: "bundle exec rake"
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ 1.1.0
2
+ - Modifies service_rpc to use chunked transfer (https://github.com/gitlabhq/grack/pull/1)
data/lib/grack/server.rb CHANGED
@@ -55,6 +55,12 @@ module Grack
55
55
  # actual command handling functions
56
56
  # ---------------------------------
57
57
 
58
+ # Uses chunked (streaming) transfer, otherwise response
59
+ # blocks to calculate Content-Length header
60
+ # http://en.wikipedia.org/wiki/Chunked_transfer_encoding
61
+
62
+ CRLF = "\r\n"
63
+
58
64
  def service_rpc
59
65
  return render_no_access if !has_access(@rpc, true)
60
66
  input = read_body
@@ -62,19 +68,32 @@ module Grack
62
68
  @res = Rack::Response.new
63
69
  @res.status = 200
64
70
  @res["Content-Type"] = "application/x-git-%s-result" % @rpc
71
+ @res["Transfer-Encoding"] = "chunked"
72
+ @res["Cache-Control"] = "no-cache"
73
+
65
74
  @res.finish do
66
75
  command = git_command("#{@rpc} --stateless-rpc #{@dir}")
67
76
  IO.popen(command, File::RDWR) do |pipe|
68
77
  pipe.write(input)
69
78
  pipe.close_write
70
79
  while !pipe.eof?
71
- block = pipe.read(8192) # 8M at a time
72
- @res.write block # steam it to the client
80
+ block = pipe.read(8192) # 8KB at a time
81
+ @res.write encode_chunk(block) # stream it to the client
73
82
  end
83
+ @res.write terminating_chunk
74
84
  end
75
85
  end
76
86
  end
77
87
 
88
+ def encode_chunk(chunk)
89
+ size_in_hex = chunk.size.to_s(16)
90
+ [ size_in_hex, CRLF, chunk, CRLF ].join
91
+ end
92
+
93
+ def terminating_chunk
94
+ [ 0, CRLF, CRLF ].join
95
+ end
96
+
78
97
  def get_info_refs
79
98
  service_name = get_service_type
80
99
 
data/lib/grack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Grack
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-grack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-10 00:00:00.000000000 Z
11
+ date: 2013-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -47,6 +47,8 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - .gitignore
49
49
  - .gitmodules
50
+ - .travis.yml
51
+ - CHANGELOG
50
52
  - Gemfile
51
53
  - Gemfile.lock
52
54
  - README.md
@@ -79,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
81
  version: '0'
80
82
  requirements: []
81
83
  rubyforge_project:
82
- rubygems_version: 2.0.3
84
+ rubygems_version: 2.1.11
83
85
  signing_key:
84
86
  specification_version: 4
85
87
  summary: Ruby/Rack Git Smart-HTTP Server Handler