glebtv-httpclient 3.2.4 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -17,6 +17,7 @@ require 'webrick/httpproxy.rb'
17
17
  require 'webrick/httputils'
18
18
  require 'tempfile'
19
19
  require 'zlib'
20
+ require 'climate_control'
20
21
  require 'httpclient'
21
22
 
22
23
  require File.join(File.dirname(__FILE__), "support", "base_server.rb")
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  class BaseServer
4
- attr_accessor :server, :port, :logger
4
+ attr_accessor :server, :port, :logger, :io
5
5
 
6
6
  def u(str = '')
7
7
  "http://localhost:#{@port}/#{str}"
@@ -9,7 +9,7 @@ class BaseServer
9
9
 
10
10
  def set_logger
11
11
  @io = StringIO.new
12
- @logger = Logger.new(@proxyio)
12
+ @logger = Logger.new(@io)
13
13
  @logger.level = Logger::Severity::DEBUG
14
14
  end
15
15
 
@@ -2,10 +2,33 @@ module HtHelpers
2
2
  def params(str)
3
3
  HTTP::Message.parse(str).inject({}) { |r, (k, v)| r[k] = v.first; r }
4
4
  end
5
+ def check_query_get(query)
6
+ WEBrick::HTTPUtils.parse_query(@client.get(@srv.u("servlet"), query).header["x-query"][0])
7
+ end
8
+ def check_query_post(query)
9
+ WEBrick::HTTPUtils.parse_query(@client.post(@srv.u("servlet"), query).header["x-query"][0])
10
+ end
11
+
12
+ def without_noproxy
13
+ backup = HTTPClient::NO_PROXY_HOSTS.dup
14
+ HTTPClient::NO_PROXY_HOSTS.clear
15
+ yield
16
+ ensure
17
+ HTTPClient::NO_PROXY_HOSTS.replace(backup)
18
+ end
19
+
20
+ def silent
21
+ begin
22
+ back, $VERBOSE = $VERBOSE, nil
23
+ yield
24
+ ensure
25
+ $VERBOSE = back
26
+ end
27
+ end
5
28
  end
6
29
 
7
30
  RSpec.configure do |config|
8
- config.extend HtHelpers
31
+ config.include HtHelpers
9
32
  config.include HTTPClient::Util
10
33
  end
11
34
 
@@ -26,6 +26,11 @@ class TestServlet < WEBrick::HTTPServlet::AbstractServlet
26
26
  res.body = param['txt'] || 'put'
27
27
  end
28
28
 
29
+ def do_PATCH(req, res)
30
+ res.body = 'patch'
31
+ res["x-query"] = body_response(req)
32
+ end
33
+
29
34
  def do_DELETE(req, res)
30
35
  res.body = 'delete'
31
36
  end
@@ -1,8 +1,4 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('helper', File.dirname(__FILE__))
3
-
4
-
5
- class TestHTTPClient < Test::Unit::TestCase
1
+ class TestHTTPClient < ActiveSupport::TestCase
6
2
  include Helper
7
3
  include HTTPClient::Util
8
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-httpclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-15 00:00:00.000000000 Z
12
+ date: 2014-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lru_redux
@@ -109,6 +109,34 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: climate_control
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspecify
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
112
140
  description:
113
141
  email: glebtv@gmail.com
114
142
  executables:
@@ -164,7 +192,9 @@ files:
164
192
  - sample/stream.rb
165
193
  - sample/thread.rb
166
194
  - sample/wcat.rb
195
+ - spec/basic_spec.rb
167
196
  - spec/cookie_spec.rb
197
+ - spec/hexdump_spec.rb
168
198
  - spec/http_message_spec.rb
169
199
  - spec/httpclient_spec.rb
170
200
  - spec/keepalive_spec.rb
@@ -196,7 +226,6 @@ files:
196
226
  - test/sslsvr.rb
197
227
  - test/subca.cert
198
228
  - test/test_auth.rb
199
- - test/test_hexdump.rb
200
229
  - test/test_httpclient.rb
201
230
  - test/test_include_client.rb
202
231
  - test/test_ssl.rb
@@ -225,7 +254,9 @@ signing_key:
225
254
  specification_version: 4
226
255
  summary: Fork of httpclient with some fixes and patches I needed.
227
256
  test_files:
257
+ - spec/basic_spec.rb
228
258
  - spec/cookie_spec.rb
259
+ - spec/hexdump_spec.rb
229
260
  - spec/http_message_spec.rb
230
261
  - spec/httpclient_spec.rb
231
262
  - spec/keepalive_spec.rb
@@ -251,7 +282,6 @@ test_files:
251
282
  - test/sslsvr.rb
252
283
  - test/subca.cert
253
284
  - test/test_auth.rb
254
- - test/test_hexdump.rb
255
285
  - test/test_httpclient.rb
256
286
  - test/test_include_client.rb
257
287
  - test/test_ssl.rb
data/test/test_hexdump.rb DELETED
@@ -1,14 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('helper', File.dirname(__FILE__))
3
- require 'hexdump'
4
-
5
-
6
- class TestHexDump < Test::Unit::TestCase
7
- def test_encode
8
- str = "\032l\277\370\2429\216\236\351[{\{\262\350\274\376"
9
- str.force_encoding('BINARY') if str.respond_to?(:force_encoding)
10
- assert_equal(["00000000 1a6cbff8 a2398e9e e95b7b7b b2e8bcfe .l...9...[{{...."], HexDump.encode(str))
11
- end
12
- end if defined?(RUBY_ENGINE) && RUBY_ENGINE != "rbx" && RUBY_VERSION >= "1.9.0"
13
- # Rubinius 1.8 mode does not support Regexp.quote(raw, 'n') I don't want put
14
- # a pressure on supporting it because 1.9 mode works fine.