rails-threaded-proxy 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/threaded_proxy/client.rb +3 -4
- data/lib/threaded_proxy/controller.rb +6 -1
- data/rails-threaded-proxy.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 67d445144a447e246d05ce8b70eeb0d7d12f209f842bc0c7253e47d1aa172aa6
|
|
4
|
+
data.tar.gz: 2fa990229d510d47e56f787f2a8901d0f837988d2d979a94fd6627ade95bf1b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb263f91b43ecea9118da5a0c8612577c56dee6f395d027b66d0f6b80aa0ded6cf0a6a6b3ffc329c24aa0d2b383713ca8d02fafd20504134fedfb62671807814
|
|
7
|
+
data.tar.gz: cf2d19158dd8784f9f2a66a1ae82ae5529b9393e6108da7a11df9e1869bd3e8d2f9d4a56119ef207db3250ee121d7648e23f4b5e5dd3fa6a864dc28f216bb5d2
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
|
@@ -23,7 +23,7 @@ module ThreadedProxy
|
|
|
23
23
|
|
|
24
24
|
def initialize(origin_url, options={})
|
|
25
25
|
@origin_url = Addressable::URI.parse(origin_url)
|
|
26
|
-
@options =
|
|
26
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def log(message)
|
|
@@ -32,12 +32,11 @@ module ThreadedProxy
|
|
|
32
32
|
|
|
33
33
|
def start(socket)
|
|
34
34
|
request_method = METHODS[(@options[:method] || 'GET').to_s.downcase]
|
|
35
|
-
http_request = request_method.new(@origin_url,
|
|
36
|
-
if
|
|
35
|
+
http_request = request_method.new(@origin_url, @options[:headers].merge('Connection' => 'close'))
|
|
36
|
+
if @options[:body].respond_to?(:read)
|
|
37
37
|
http_request.body_stream = @options[:body]
|
|
38
38
|
elsif String === @options[:body]
|
|
39
39
|
http_request.body = @options[:body]
|
|
40
|
-
@options[:headers]['Content-Length'] = @options[:body].bytesize.to_s
|
|
41
40
|
end
|
|
42
41
|
|
|
43
42
|
http = HTTP.new(@origin_url.host, @origin_url.port || default_port(@origin_url))
|
|
@@ -11,13 +11,18 @@ module ThreadedProxy
|
|
|
11
11
|
if options[:body] == :rack
|
|
12
12
|
options[:headers] ||= {}
|
|
13
13
|
options[:body] = request.body_stream
|
|
14
|
+
|
|
14
15
|
if request.env['HTTP_TRANSFER_ENCODING'] == 'chunked'
|
|
15
16
|
options[:headers]['Transfer-Encoding'] = 'chunked'
|
|
16
17
|
elsif request.env['CONTENT_LENGTH']
|
|
17
|
-
options[:headers]['
|
|
18
|
+
options[:headers]['content-length'] = request.env['CONTENT_LENGTH'].to_s
|
|
18
19
|
else
|
|
19
20
|
raise "Cannot proxy a non-chunked POST request without content-length"
|
|
20
21
|
end
|
|
22
|
+
|
|
23
|
+
if request.env['CONTENT_TYPE']
|
|
24
|
+
options[:headers]['Content-Type'] = request.env['CONTENT_TYPE']
|
|
25
|
+
end
|
|
21
26
|
end
|
|
22
27
|
|
|
23
28
|
client = Client.new(origin_url, options)
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: rails-threaded-proxy 0.
|
|
5
|
+
# stub: rails-threaded-proxy 0.2.0 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "rails-threaded-proxy".freeze
|
|
9
|
-
s.version = "0.
|
|
9
|
+
s.version = "0.2.0".freeze
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.require_paths = ["lib".freeze]
|