rails-threaded-proxy 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: 97a50696507952bcd8658bcecce9e784ed9f627a10c7add96e0942d0e7806e9a
4
- data.tar.gz: 75767119d8493f4913b977e27e0d67dadfab57e6ed3cbade742d2ca5db9e4c49
3
+ metadata.gz: 67d445144a447e246d05ce8b70eeb0d7d12f209f842bc0c7253e47d1aa172aa6
4
+ data.tar.gz: 2fa990229d510d47e56f787f2a8901d0f837988d2d979a94fd6627ade95bf1b9
5
5
  SHA512:
6
- metadata.gz: c04a9f03a0b19c139c9de59c00dfa7f49a5e6b3bdaafe1cb1db6f23b0d6ef623c60c30be5e5e08f68517915317f2764bc394bd82da36e65ef52c365641b1dc81
7
- data.tar.gz: e6368a368ca91d818de566c6884b1840c95ff76665e18d5b8256a88b28c18048f22c52e1f771a8c5348bb9e4d02f9f91022e62c682d3cf7b4f5bd7601ec4891a
6
+ metadata.gz: eb263f91b43ecea9118da5a0c8612577c56dee6f395d027b66d0f6b80aa0ded6cf0a6a6b3ffc329c24aa0d2b383713ca8d02fafd20504134fedfb62671807814
7
+ data.tar.gz: cf2d19158dd8784f9f2a66a1ae82ae5529b9393e6108da7a11df9e1869bd3e8d2f9d4a56119ef207db3250ee121d7648e23f4b5e5dd3fa6a864dc28f216bb5d2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.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 = options.merge(DEFAULT_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, (@options[:headers] || {}).merge('Connection' => 'close'))
36
- if IO === @options[:body]
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]['Content-Length'] = request.env['CONTENT_LENGTH'].to_s
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.1.0 ruby lib
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.1.0".freeze
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]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-threaded-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Nutt