httpclient 2.3.2 → 2.3.3

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.
data/README.txt CHANGED
@@ -107,6 +107,15 @@ Thanks in advance.
107
107
 
108
108
  == Changes
109
109
 
110
+ = Changes in 2.3.3 =
111
+
112
+ February 24, 2013 - version 2.3.3
113
+
114
+ * Changes
115
+
116
+ * #144 Add User-Agent field by default. You can remove the header by
117
+ setting nil to HTTPClient#agent_name.
118
+
110
119
  = Changes in 2.3.2 =
111
120
 
112
121
  January 5, 2013 - version 2.3.2
data/lib/httpclient.rb CHANGED
@@ -229,7 +229,7 @@ require 'httpclient/cookie'
229
229
  # ruby -rhttpclient -e 'p HTTPClient.head(ARGV.shift).header["last-modified"]' http://dev.ctor.org/
230
230
  #
231
231
  class HTTPClient
232
- RUBY_VERSION_STRING = "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
232
+ RUBY_VERSION_STRING = "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
233
233
  LIB_NAME = "(#{VERSION}, #{RUBY_VERSION_STRING})"
234
234
 
235
235
  include Util
@@ -357,6 +357,9 @@ class HTTPClient
357
357
  # Default header for PROPFIND request.
358
358
  PROPFIND_DEFAULT_EXTHEADER = { 'Depth' => '0' }
359
359
 
360
+ # Default User-Agent header
361
+ DEFAULT_AGENT_NAME = 'HTTPClient/1.0'
362
+
360
363
  # Creates a HTTPClient instance which manages sessions, cookies, etc.
361
364
  #
362
365
  # HTTPClient.new takes 3 optional arguments for proxy url string,
@@ -385,7 +388,7 @@ class HTTPClient
385
388
  @redirect_uri_callback = method(:default_redirect_uri_callback)
386
389
  @test_loopback_response = []
387
390
  @session_manager = SessionManager.new(self)
388
- @session_manager.agent_name = agent_name
391
+ @session_manager.agent_name = agent_name || DEFAULT_AGENT_NAME
389
392
  @session_manager.from = from
390
393
  @session_manager.ssl_config = @ssl_config = SSLConfig.new(self)
391
394
  @cookie_manager = WebAgent::CookieManager.new
@@ -726,10 +726,10 @@ class HTTPClient
726
726
  req.http_version = $1
727
727
  end
728
728
  end
729
- if @agent_name
729
+ if @agent_name && req.header.get('User-Agent').empty?
730
730
  req.header.set('User-Agent', "#{@agent_name} #{LIB_NAME}")
731
731
  end
732
- if @from
732
+ if @from && req.header.get('From').empty?
733
733
  req.header.set('From', @from)
734
734
  end
735
735
  if req.header.get('Accept').empty?
@@ -1,3 +1,3 @@
1
1
  class HTTPClient
2
- VERSION = '2.3.2'
2
+ VERSION = '2.3.3'
3
3
  end
@@ -47,7 +47,7 @@ class TestClient < Test::Unit::TestCase
47
47
  @client.get(serverurl)
48
48
  lines = str.split(/(?:\r?\n)+/)
49
49
  assert_equal("= Request", lines[0])
50
- assert_match(/^From: from_bar/, lines[4])
50
+ assert_match(/^From: from_bar/, lines[5])
51
51
  end
52
52
 
53
53
  def test_debug_dev
@@ -81,8 +81,8 @@ class TestClient < Test::Unit::TestCase
81
81
  assert_equal("= Request", lines[0])
82
82
  assert_equal("! CONNECTION ESTABLISHED", lines[2])
83
83
  assert_equal("GET /hello HTTP/1.0", lines[3])
84
- assert_equal("Connection: close", lines[6])
85
- assert_equal("= Response", lines[7])
84
+ assert_equal("Connection: close", lines[7])
85
+ assert_equal("= Response", lines[8])
86
86
  end
87
87
 
88
88
  def test_protocol_version_http11
@@ -93,7 +93,7 @@ class TestClient < Test::Unit::TestCase
93
93
  assert_equal("= Request", lines[0])
94
94
  assert_equal("! CONNECTION ESTABLISHED", lines[2])
95
95
  assert_equal("GET / HTTP/1.1", lines[3])
96
- assert_equal("Host: localhost:#{serverport}", lines[6])
96
+ assert_equal("Host: localhost:#{serverport}", lines[7])
97
97
  @client.protocol_version = 'HTTP/1.1'
98
98
  str = ""
99
99
  @client.debug_dev = str
@@ -44,7 +44,7 @@ class TestHTTPClient < Test::Unit::TestCase
44
44
  @client.get(serverurl)
45
45
  lines = str.split(/(?:\r?\n)+/)
46
46
  assert_equal("= Request", lines[0])
47
- assert_match(/^From: from_bar/, lines[4])
47
+ assert_match(/^From: from_bar/, lines[5])
48
48
  end
49
49
 
50
50
  def test_debug_dev
@@ -77,10 +77,10 @@ class TestHTTPClient < Test::Unit::TestCase
77
77
  assert_equal("= Request", lines[0])
78
78
  assert_equal("! CONNECTION ESTABLISHED", lines[2])
79
79
  assert_equal("GET /hello HTTP/0.9", lines[3])
80
- assert_equal("Connection: close", lines[6])
81
- assert_equal("= Response", lines[7])
82
- assert_match(/^hello$/, lines[8])
83
- assert_match(/^world$/, lines[9])
80
+ assert_equal("Connection: close", lines[7])
81
+ assert_equal("= Response", lines[8])
82
+ assert_match(/^hello$/, lines[9])
83
+ assert_match(/^world$/, lines[10])
84
84
  end
85
85
 
86
86
  def test_protocol_version_http10
@@ -94,8 +94,8 @@ class TestHTTPClient < Test::Unit::TestCase
94
94
  assert_equal("= Request", lines[0])
95
95
  assert_equal("! CONNECTION ESTABLISHED", lines[2])
96
96
  assert_equal("GET /hello HTTP/1.0", lines[3])
97
- assert_equal("Connection: close", lines[6])
98
- assert_equal("= Response", lines[7])
97
+ assert_equal("Connection: close", lines[7])
98
+ assert_equal("= Response", lines[8])
99
99
  end
100
100
 
101
101
  def test_header_accept_by_default
@@ -103,7 +103,7 @@ class TestHTTPClient < Test::Unit::TestCase
103
103
  @client.debug_dev = str
104
104
  @client.get(serverurl)
105
105
  lines = str.split(/(?:\r?\n)+/)
106
- assert_equal("Accept: */*", lines[4])
106
+ assert_equal("Accept: */*", lines[5])
107
107
  end
108
108
 
109
109
  def test_header_accept
@@ -122,7 +122,7 @@ class TestHTTPClient < Test::Unit::TestCase
122
122
  assert_equal("= Request", lines[0])
123
123
  assert_equal("! CONNECTION ESTABLISHED", lines[2])
124
124
  assert_equal("GET / HTTP/1.1", lines[3])
125
- assert_equal("Host: localhost:#{serverport}", lines[6])
125
+ assert_equal("Host: localhost:#{serverport}", lines[7])
126
126
  #
127
127
  @client.reset_all
128
128
  str = ""
@@ -152,7 +152,7 @@ class TestHTTPClient < Test::Unit::TestCase
152
152
  assert_equal("= Request", lines[0])
153
153
  assert_equal("! CONNECTION ESTABLISHED", lines[2])
154
154
  assert_equal("GET / HTTP/1.1", lines[3])
155
- assert_equal("Host: localhost:#{serverport}", lines[6])
155
+ assert_equal("Host: localhost:#{serverport}", lines[7])
156
156
  @client.protocol_version = 'HTTP/1.1'
157
157
  assert_equal('HTTP/1.1', @client.protocol_version)
158
158
  str = ""
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-05 00:00:00.000000000 Z
12
+ date: 2013-02-24 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: nahi@ruby-lang.org
@@ -87,18 +87,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
87
  - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
- segments:
91
- - 0
92
- hash: -3461181024347964072
93
90
  required_rubygems_version: !ruby/object:Gem::Requirement
94
91
  none: false
95
92
  requirements:
96
93
  - - ! '>='
97
94
  - !ruby/object:Gem::Version
98
95
  version: '0'
99
- segments:
100
- - 0
101
- hash: -3461181024347964072
102
96
  requirements: []
103
97
  rubyforge_project:
104
98
  rubygems_version: 1.8.23
@@ -106,3 +100,4 @@ signing_key:
106
100
  specification_version: 3
107
101
  summary: gives something like the functionality of libwww-perl (LWP) in Ruby
108
102
  test_files: []
103
+ has_rdoc: