jruby-httpclient 0.4.0-java → 1.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 1.0.0
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jruby-httpclient}
8
- s.version = "0.4.0"
8
+ s.version = "1.0.0"
9
9
  s.platform = Gem::Platform.new([nil, "java", nil])
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Adam Esterline"]
13
- s.date = %q{2011-07-01}
13
+ s.date = %q{2011-07-10}
14
14
  s.description = %q{An HTTP client designed for use with JRuby in a threaded environment}
15
15
  s.email = %q{adam@esterlines.com}
16
16
  s.extra_rdoc_files = [
@@ -27,18 +27,22 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "jruby-httpclient.gemspec",
29
29
  "lib/http_client.rb",
30
- "lib/http_client/client.rb",
31
- "lib/http_client/client_configuration.rb",
32
- "lib/http_client/methods.rb",
33
- "lib/http_client/response.rb",
30
+ "lib/http_client/jruby/client.rb",
31
+ "lib/http_client/jruby/client_configuration.rb",
32
+ "lib/http_client/jruby/methods.rb",
33
+ "lib/http_client/jruby/response.rb",
34
+ "lib/http_client/mri/client.rb",
35
+ "lib/http_client/mri/methods.rb",
36
+ "lib/http_client/mri/response.rb",
37
+ "lib/http_client/status.rb",
34
38
  "test/helper.rb",
39
+ "test/http_client/jruby/test_client_configuration.rb",
35
40
  "test/http_client/test_basic_auth.rb",
36
41
  "test/http_client/test_basic_client_operations.rb",
37
- "test/http_client/test_client_configuration.rb",
38
42
  "test/http_client/test_client_headers.rb",
39
43
  "test/http_client/test_cookies.rb",
40
44
  "test/http_client/test_redirect.rb",
41
- "test/http_client/test_request_entity.rb",
45
+ "test/http_client/test_request_body.rb",
42
46
  "test/http_client/test_response.rb",
43
47
  "test/http_client/test_server_headers.rb",
44
48
  "test/http_test_server.rb",
@@ -1,18 +1,32 @@
1
1
  HTTP_CLIENT_DIR = File.join(File.dirname(__FILE__), 'http_client')
2
- VENDOR_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor'))
3
-
4
2
  $LOAD_PATH.unshift(HTTP_CLIENT_DIR) unless $LOAD_PATH.include?(HTTP_CLIENT_DIR)
5
- $LOAD_PATH.unshift(VENDOR_DIR) unless $LOAD_PATH.include?(VENDOR_DIR)
6
3
 
7
- require 'java'
8
- require 'commons-logging-1.1.1'
9
- require 'commons-codec-1.4'
10
- require 'httpcore-4.1'
11
- require 'httpmime-4.1.1'
12
- require 'httpclient-4.1.1'
13
- require 'httpclient-cache-4.1.1'
4
+ require 'status'
5
+
6
+ if defined?(JRUBY_VERSION)
7
+ JRUBY_HTTP_CLIENT_DIR = File.join(HTTP_CLIENT_DIR, 'jruby')
8
+ VENDOR_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor'))
9
+
10
+ $LOAD_PATH.unshift(JRUBY_HTTP_CLIENT_DIR) unless $LOAD_PATH.include?(JRUBY_HTTP_CLIENT_DIR)
11
+ $LOAD_PATH.unshift(VENDOR_DIR) unless $LOAD_PATH.include?(VENDOR_DIR)
12
+
13
+ require 'java'
14
+ require 'commons-logging-1.1.1'
15
+ require 'commons-codec-1.4'
16
+ require 'httpcore-4.1'
17
+ require 'httpmime-4.1.1'
18
+ require 'httpclient-4.1.1'
19
+ require 'httpclient-cache-4.1.1'
20
+
21
+ require 'client_configuration'
22
+ else
23
+ MRI_HTTP_CLIENT_DIR = File.join(HTTP_CLIENT_DIR, 'mri')
24
+ $LOAD_PATH.unshift(MRI_HTTP_CLIENT_DIR) unless $LOAD_PATH.include?(MRI_HTTP_CLIENT_DIR)
25
+
26
+ require 'net/http'
27
+ require 'cgi'
28
+ end
14
29
 
15
- require 'client_configuration'
16
- require 'response'
17
30
  require 'methods'
31
+ require 'response'
18
32
  require 'client'
@@ -0,0 +1,42 @@
1
+ module HTTP
2
+ class Response
3
+ attr_reader :headers, :cookies
4
+
5
+ def initialize(native_response, cookies)
6
+ @native_response = native_response
7
+ @headers = Headers.new(native_response)
8
+ @cookies = Cookies.new(cookies)
9
+ end
10
+
11
+ def body
12
+ @body ||= EntityUtils.to_string(@native_response.entity)
13
+ end
14
+
15
+ def status_code
16
+ @native_response.status_line.status_code
17
+ end
18
+ end
19
+
20
+ private
21
+ EntityUtils = org.apache.http.util.EntityUtils
22
+
23
+ class Headers
24
+ def initialize(native_response)
25
+ @native_response = native_response
26
+ end
27
+
28
+ def [](header_name)
29
+ @native_response.get_first_header(header_name).value
30
+ end
31
+ end
32
+
33
+ class Cookies
34
+ def initialize(cookies)
35
+ @cookies = cookies
36
+ end
37
+
38
+ def [](cookie_name)
39
+ @cookies.find {|cookie| cookie.name == cookie_name }.value
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,51 @@
1
+ module HTTP
2
+ class Client
3
+ def initialize(options)
4
+ @default_host = options[:default_host]
5
+ @timeout_in_seconds = options[:timeout_in_seconds]
6
+ @uri = URI.parse(@default_host)
7
+ end
8
+
9
+ def get(url, params = {})
10
+ execute(HTTP::Get.new(url, params)).body
11
+ end
12
+
13
+ def post(url, params = {})
14
+ execute(HTTP::Post.new(url, params)).body
15
+ end
16
+
17
+ def delete(url)
18
+ execute(HTTP::Delete.new(url)).body
19
+ end
20
+
21
+ def put(url)
22
+ execute(HTTP::Put.new(url)).body
23
+ end
24
+
25
+ def execute(req)
26
+ req.execute_native_request(self)
27
+ end
28
+
29
+ def execute_request(requested_host, requested_port, req)
30
+ host = requested_host || @uri.host
31
+ port = requested_port || @uri.port
32
+ req['Cookie'] = @cookie unless @cookie.nil?
33
+
34
+ Net::HTTP.new(host, port).start do |http|
35
+ http.read_timeout = @timeout_in_seconds || 30
36
+ response = http.request(req)
37
+
38
+ if response['location']
39
+ redirect_uri = URI.parse(response['location'])
40
+ return execute_request(redirect_uri.host, redirect_uri.port, Net::HTTP::Get.new("#{redirect_uri.path}?#{redirect_uri.query}"))
41
+ end
42
+
43
+ @cookie = response['set-cookie']
44
+
45
+ response
46
+ end
47
+ end
48
+
49
+ def shutdown; end
50
+ end
51
+ end
@@ -0,0 +1,87 @@
1
+ module HTTP
2
+ class Request
3
+ def initialize(url, params = {})
4
+ @requested_uri = url
5
+ @params = params
6
+ @headers = {}
7
+ end
8
+
9
+ def basic_auth(username, password)
10
+ @username = username
11
+ @password = password
12
+ end
13
+
14
+ def add_headers(headers)
15
+ @headers = headers
16
+ end
17
+
18
+ def content_type=(content_type)
19
+ @content_type = content_type
20
+ end
21
+
22
+ def body=(body)
23
+ @body = body
24
+ end
25
+
26
+ def execute_native_request(client)
27
+ host, port, req = create_request
28
+ req.basic_auth(@username, @password)
29
+
30
+ @headers.each {|name, value| req[name.to_s] = value.to_s}
31
+ req.content_type = @content_type unless @content_type.nil?
32
+ req.body = @body unless @body.nil?
33
+
34
+ HTTP::Response.new(client.execute_request(host, port, req))
35
+ end
36
+
37
+ private
38
+
39
+ def parse_uri
40
+ request_uri = URI.parse(@requested_uri)
41
+
42
+ host = request_uri.host
43
+ port = request_uri.port
44
+ path = request_uri.path
45
+ query = request_uri.query
46
+
47
+ [host, port, path, query]
48
+ end
49
+ end
50
+
51
+ class Get < Request
52
+ def create_request
53
+ host, port, path, query = parse_uri
54
+ get = Net::HTTP::Get.new("#{path}?#{query || to_query_string(@params)}")
55
+ [host, port, get]
56
+ end
57
+
58
+ def to_query_string(params_as_hash)
59
+ params_as_hash.map { |name, value| "#{URI.encode(name.to_s)}=#{URI.encode(value.to_s)}" }.join("&")
60
+ end
61
+ end
62
+
63
+ class Post < Request
64
+ def create_request
65
+ host, port, path, query = parse_uri
66
+ post = Net::HTTP::Post.new(path)
67
+ post.set_form_data(@params)
68
+ [host, port, post]
69
+ end
70
+ end
71
+
72
+ class Put < Request
73
+ def create_request
74
+ host, port, path, query = parse_uri
75
+ put = Net::HTTP::Put.new(path)
76
+ [host, port, put]
77
+ end
78
+ end
79
+
80
+ class Delete < Request
81
+ def create_request
82
+ host, port, path, query = parse_uri
83
+ delete = Net::HTTP::Delete.new(path)
84
+ [host, port, delete]
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,22 @@
1
+ module HTTP
2
+ class Response
3
+ attr_reader :status_code, :body
4
+
5
+ def initialize(native_response)
6
+ @native_response = native_response
7
+ @status_code = native_response.code.to_i
8
+ @body = native_response.body
9
+ end
10
+
11
+ def headers
12
+ @native_response
13
+ end
14
+
15
+ def cookies
16
+ native_cookies = CGI::Cookie.parse(@native_response['set-cookie'])
17
+ cookies = {}
18
+ native_cookies.each {|name, cookie| cookies[name] = cookie.value.first}
19
+ cookies
20
+ end
21
+ end
22
+ end
@@ -1,23 +1,5 @@
1
1
  module HTTP
2
- class Response
3
- attr_reader :headers, :cookies
4
-
5
- def initialize(native_response, cookies)
6
- @native_response = native_response
7
- @headers = Headers.new(native_response)
8
- @cookies = Cookies.new(cookies)
9
- end
10
-
11
- def body
12
- @body ||= EntityUtils.to_string(@native_response.entity)
13
- end
14
-
15
- def status_code
16
- @native_response.status_line.status_code
17
- end
18
- end
19
-
20
- module Status
2
+ module Status
21
3
  ACCEPTED = 202
22
4
  BAD_GATEWAY = 502
23
5
  BAD_REQUEST = 400
@@ -67,27 +49,4 @@ module HTTP
67
49
  UNSUPPORTED_MEDIA_TYPE = 415
68
50
  USE_PROXY = 305
69
51
  end
70
-
71
- private
72
- EntityUtils = org.apache.http.util.EntityUtils
73
-
74
- class Headers
75
- def initialize(native_response)
76
- @native_response = native_response
77
- end
78
-
79
- def [](header_name)
80
- @native_response.get_first_header(header_name).value
81
- end
82
- end
83
-
84
- class Cookies
85
- def initialize(cookies)
86
- @cookies = cookies
87
- end
88
-
89
- def [](cookie_name)
90
- @cookies.find {|cookie| cookie.name == cookie_name }.value
91
- end
92
- end
93
52
  end
@@ -0,0 +1,136 @@
1
+ require 'helper'
2
+
3
+ if defined?(JRUBY_VERSION)
4
+ class TestClientConfiguration < Test::Unit::TestCase
5
+ def test_protocol_version
6
+ config = HTTP::ClientConfiguration.new(:protocol_version => "HTTP 1.0")
7
+ assert_equal(config.protocol_version.to_s, "HTTP/1.0")
8
+ end
9
+
10
+ def test_strict_transfer_encodeing
11
+ config = HTTP::ClientConfiguration.new(:strict_transfer_encoding => true)
12
+ assert_equal(config.strict_transfer_encoding, true)
13
+ end
14
+
15
+ def test_http_element_charset
16
+ config = HTTP::ClientConfiguration.new(:http_element_charset => "ASCII")
17
+ assert_equal(config.http_element_charset, "ASCII")
18
+ end
19
+
20
+ def test_use_expect_continue
21
+ config = HTTP::ClientConfiguration.new(:use_expect_continue => true)
22
+ assert_equal(config.use_expect_continue, true)
23
+ end
24
+
25
+ def test_wait_for_continue
26
+ config = HTTP::ClientConfiguration.new(:wait_for_continue => true)
27
+ assert_equal(config.wait_for_continue, true)
28
+ end
29
+
30
+ def test_user_agent
31
+ user_agent_name = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3"
32
+ config = HTTP::ClientConfiguration.new(:user_agent => user_agent_name)
33
+ assert_equal(config.user_agent, user_agent_name)
34
+ end
35
+
36
+ def test_tcp_nodelay
37
+ config = HTTP::ClientConfiguration.new(:tcp_nodelay => true)
38
+ assert_equal(config.tcp_nodelay, true)
39
+ end
40
+
41
+ def test_so_linger
42
+ config = HTTP::ClientConfiguration.new(:so_linger => 3000)
43
+ assert_equal(config.so_linger, 3000)
44
+ end
45
+
46
+ def test_so_reuseaddr
47
+ config = HTTP::ClientConfiguration.new(:so_reuseaddr => true)
48
+ assert_equal(config.so_reuseaddr, true)
49
+ end
50
+
51
+ def test_socket_buffer_size
52
+ config = HTTP::ClientConfiguration.new(:socket_buffer_size => 10000)
53
+ assert_equal(config.socket_buffer_size, 10000)
54
+ end
55
+
56
+ def test_connection_timeout
57
+ config = HTTP::ClientConfiguration.new(:connection_timeout => 2)
58
+ assert_equal(config.connection_timeout, 2)
59
+ end
60
+
61
+ def test_max_line_length
62
+ config = HTTP::ClientConfiguration.new(:max_line_length => 2)
63
+ assert_equal(config.max_line_length, 2)
64
+ end
65
+
66
+ def test_max_header_count
67
+ config = HTTP::ClientConfiguration.new(:max_header_count => 10)
68
+ assert_equal(config.max_header_count, 10)
69
+ end
70
+
71
+ def test_stale_connection_check
72
+ config = HTTP::ClientConfiguration.new(:stale_connection_check => true)
73
+ assert_equal(config.stale_connection_check, true)
74
+ end
75
+
76
+ def test_local_address
77
+ config = HTTP::ClientConfiguration.new(:local_address => "127.0.0.1")
78
+ assert_equal(config.local_address.get_host_address, "127.0.0.1")
79
+ end
80
+
81
+ def test_default_proxy
82
+ config = HTTP::ClientConfiguration.new(:default_proxy => "http://127.0.0.1:8080")
83
+ assert_equal(config.default_proxy.to_s, "http://127.0.0.1:8080")
84
+ end
85
+
86
+ def test_date_patterns
87
+ config = HTTP::ClientConfiguration.new(:date_patterns => ["MDy"])
88
+ assert(config.date_patterns.include? 'MDy')
89
+ end
90
+
91
+ def test_single_cookie_header
92
+ config = HTTP::ClientConfiguration.new(:single_cookie_header => true)
93
+ assert_equal(config.single_cookie_header, true)
94
+ end
95
+
96
+ def test_credential_charset
97
+ config = HTTP::ClientConfiguration.new(:credential_charset => "ASCII")
98
+ assert_equal(config.credential_charset, "ASCII")
99
+ end
100
+
101
+ def test_cookie_policy
102
+ config = HTTP::ClientConfiguration.new(:cookie_policy => "RFC2109")
103
+ assert_equal(config.cookie_policy, "RFC2109")
104
+ end
105
+
106
+ def test_handle_authentication
107
+ config = HTTP::ClientConfiguration.new(:handle_authentication => true)
108
+ assert_equal(config.handle_authentication, true)
109
+ end
110
+
111
+ def test_handle_redirects
112
+ config = HTTP::ClientConfiguration.new(:handle_redirects => true)
113
+ assert_equal(config.handle_redirects, true)
114
+ end
115
+
116
+ def test_max_redirects
117
+ config = HTTP::ClientConfiguration.new(:max_redirects => 1)
118
+ assert_equal(config.max_redirects, 1)
119
+ end
120
+
121
+ def test_allow_circular_redirects
122
+ config = HTTP::ClientConfiguration.new(:allow_circular_redirects => true)
123
+ assert_equal(config.allow_circular_redirects, true)
124
+ end
125
+
126
+ def test_virtual_host
127
+ config = HTTP::ClientConfiguration.new(:virtual_host => "http://127.0.0.1:80")
128
+ assert_equal(config.virtual_host.to_s, "http://127.0.0.1:80")
129
+ end
130
+
131
+ def test_default_host
132
+ config = HTTP::ClientConfiguration.new(:default_host => "http://localhost:8080")
133
+ assert_equal(config.default_host.to_s, "http://localhost:8080")
134
+ end
135
+ end
136
+ end
@@ -61,6 +61,14 @@ class TestBasicClientOperations < Test::Unit::TestCase
61
61
  assert_equal("bar", result)
62
62
  end
63
63
 
64
+ def test_timeout
65
+ client = HTTP::Client.new(:default_host => "http://localhost:8080", :timeout_in_seconds => 2)
66
+
67
+ assert_raises(Timeout::Error) do
68
+ client.get("/slow", :sleep => "30")
69
+ end
70
+ end
71
+
64
72
  def setup
65
73
  @client = HTTP::Client.new(:default_host => "http://localhost:8080")
66
74
  end
@@ -16,7 +16,7 @@ class CookieTest < Test::Unit::TestCase
16
16
  end
17
17
 
18
18
  def setup
19
- @client = HTTP::Client.new(:default_host => "http://localhost:8080", :cookie_policy => HTTP::CookiePolicy::BROWSER_COMPATIBILITY)
19
+ @client = HTTP::Client.new(:default_host => "http://localhost:8080")
20
20
  end
21
21
 
22
22
  def teardown
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jruby-httpclient
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.0
5
+ version: 1.0.0
6
6
  platform: java
7
7
  authors:
8
8
  - Adam Esterline
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-01 00:00:00 -06:00
13
+ date: 2011-07-10 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -65,18 +65,22 @@ files:
65
65
  - VERSION
66
66
  - jruby-httpclient.gemspec
67
67
  - lib/http_client.rb
68
- - lib/http_client/client.rb
69
- - lib/http_client/client_configuration.rb
70
- - lib/http_client/methods.rb
71
- - lib/http_client/response.rb
68
+ - lib/http_client/jruby/client.rb
69
+ - lib/http_client/jruby/client_configuration.rb
70
+ - lib/http_client/jruby/methods.rb
71
+ - lib/http_client/jruby/response.rb
72
+ - lib/http_client/mri/client.rb
73
+ - lib/http_client/mri/methods.rb
74
+ - lib/http_client/mri/response.rb
75
+ - lib/http_client/status.rb
72
76
  - test/helper.rb
77
+ - test/http_client/jruby/test_client_configuration.rb
73
78
  - test/http_client/test_basic_auth.rb
74
79
  - test/http_client/test_basic_client_operations.rb
75
- - test/http_client/test_client_configuration.rb
76
80
  - test/http_client/test_client_headers.rb
77
81
  - test/http_client/test_cookies.rb
78
82
  - test/http_client/test_redirect.rb
79
- - test/http_client/test_request_entity.rb
83
+ - test/http_client/test_request_body.rb
80
84
  - test/http_client/test_response.rb
81
85
  - test/http_client/test_server_headers.rb
82
86
  - test/http_test_server.rb
@@ -1,142 +0,0 @@
1
- require 'helper'
2
-
3
- class TestClientConfiguration < Test::Unit::TestCase
4
- def test_timeout
5
- client = HTTP::Client.new(:default_host => "http://localhost:8080", :timeout_in_seconds => 2)
6
-
7
- assert_raises(Timeout::Error) do
8
- client.get("/slow", :sleep => "30")
9
- end
10
- end
11
-
12
- def test_protocol_version
13
- config = HTTP::ClientConfiguration.new(:protocol_version => "HTTP 1.0")
14
- assert_equal(config.protocol_version.to_s, "HTTP/1.0")
15
- end
16
-
17
- def test_strict_transfer_encodeing
18
- config = HTTP::ClientConfiguration.new(:strict_transfer_encoding => true)
19
- assert_equal(config.strict_transfer_encoding, true)
20
- end
21
-
22
- def test_http_element_charset
23
- config = HTTP::ClientConfiguration.new(:http_element_charset => "ASCII")
24
- assert_equal(config.http_element_charset, "ASCII")
25
- end
26
-
27
- def test_use_expect_continue
28
- config = HTTP::ClientConfiguration.new(:use_expect_continue => true)
29
- assert_equal(config.use_expect_continue, true)
30
- end
31
-
32
- def test_wait_for_continue
33
- config = HTTP::ClientConfiguration.new(:wait_for_continue => true)
34
- assert_equal(config.wait_for_continue, true)
35
- end
36
-
37
- def test_user_agent
38
- user_agent_name = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3"
39
- config = HTTP::ClientConfiguration.new(:user_agent => user_agent_name)
40
- assert_equal(config.user_agent, user_agent_name)
41
- end
42
-
43
- def test_tcp_nodelay
44
- config = HTTP::ClientConfiguration.new(:tcp_nodelay => true)
45
- assert_equal(config.tcp_nodelay, true)
46
- end
47
-
48
- def test_so_linger
49
- config = HTTP::ClientConfiguration.new(:so_linger => 3000)
50
- assert_equal(config.so_linger, 3000)
51
- end
52
-
53
- def test_so_reuseaddr
54
- config = HTTP::ClientConfiguration.new(:so_reuseaddr => true)
55
- assert_equal(config.so_reuseaddr, true)
56
- end
57
-
58
- def test_socket_buffer_size
59
- config = HTTP::ClientConfiguration.new(:socket_buffer_size => 10000)
60
- assert_equal(config.socket_buffer_size, 10000)
61
- end
62
-
63
- def test_connection_timeout
64
- config = HTTP::ClientConfiguration.new(:connection_timeout => 2)
65
- assert_equal(config.connection_timeout, 2)
66
- end
67
-
68
- def test_max_line_length
69
- config = HTTP::ClientConfiguration.new(:max_line_length => 2)
70
- assert_equal(config.max_line_length, 2)
71
- end
72
-
73
- def test_max_header_count
74
- config = HTTP::ClientConfiguration.new(:max_header_count => 10)
75
- assert_equal(config.max_header_count, 10)
76
- end
77
-
78
- def test_stale_connection_check
79
- config = HTTP::ClientConfiguration.new(:stale_connection_check => true)
80
- assert_equal(config.stale_connection_check, true)
81
- end
82
-
83
- def test_local_address
84
- config = HTTP::ClientConfiguration.new(:local_address => "127.0.0.1")
85
- assert_equal(config.local_address.get_host_address, "127.0.0.1")
86
- end
87
-
88
- def test_default_proxy
89
- config = HTTP::ClientConfiguration.new(:default_proxy => "http://127.0.0.1:8080")
90
- assert_equal(config.default_proxy.to_s, "http://127.0.0.1:8080")
91
- end
92
-
93
- def test_date_patterns
94
- config = HTTP::ClientConfiguration.new(:date_patterns => ["MDy"])
95
- assert(config.date_patterns.include? 'MDy')
96
- end
97
-
98
- def test_single_cookie_header
99
- config = HTTP::ClientConfiguration.new(:single_cookie_header => true)
100
- assert_equal(config.single_cookie_header, true)
101
- end
102
-
103
- def test_credential_charset
104
- config = HTTP::ClientConfiguration.new(:credential_charset => "ASCII")
105
- assert_equal(config.credential_charset, "ASCII")
106
- end
107
-
108
- def test_cookie_policy
109
- config = HTTP::ClientConfiguration.new(:cookie_policy => "RFC2109")
110
- assert_equal(config.cookie_policy, "RFC2109")
111
- end
112
-
113
- def test_handle_authentication
114
- config = HTTP::ClientConfiguration.new(:handle_authentication => true)
115
- assert_equal(config.handle_authentication, true)
116
- end
117
-
118
- def test_handle_redirects
119
- config = HTTP::ClientConfiguration.new(:handle_redirects => true)
120
- assert_equal(config.handle_redirects, true)
121
- end
122
-
123
- def test_max_redirects
124
- config = HTTP::ClientConfiguration.new(:max_redirects => 1)
125
- assert_equal(config.max_redirects, 1)
126
- end
127
-
128
- def test_allow_circular_redirects
129
- config = HTTP::ClientConfiguration.new(:allow_circular_redirects => true)
130
- assert_equal(config.allow_circular_redirects, true)
131
- end
132
-
133
- def test_virtual_host
134
- config = HTTP::ClientConfiguration.new(:virtual_host => "http://127.0.0.1:80")
135
- assert_equal(config.virtual_host.to_s, "http://127.0.0.1:80")
136
- end
137
-
138
- def test_default_host
139
- config = HTTP::ClientConfiguration.new(:default_host => "http://localhost:8080")
140
- assert_equal(config.default_host.to_s, "http://localhost:8080")
141
- end
142
- end