diff --git a/README.markdown b/README.markdown
index 2597578..51100fe 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,7 +1,20 @@
This repo contains a number of experimental modifications to the version of Net::HTTP that ships with Ruby 1.9. TODOs:
* Porting the code to work on Ruby 1.8
-* Add missing tests for features, including gzip
-* Fixing gzip when using requests that a block as an iterator
-* Adding support for getting the response as a stream, rather than having to read the entire body at once.
+* Fix gzip in GET requests when using a block as iterator
+* Add support for gzip and deflate responses from any request
+* Add support for incremental gzip and deflate with chunked
+ encoding
+* Add support for leaving the socket open when making a request, so
+ it's possible to make requests that do not block on the body being
+ returned
+* Clean up tests so that it's possible to combine tests for
+ features, instead of using brittle checks for specific classes
+* Add support for Net::HTTP.get(path), instead of needing to pass a
+ URI or deconstruct the URL yourself
+* In keepalive situations, make sure to read any remaining body from the
+ socket before initiating a new connection.
+* Add support for partial reads from the response
+* Document and clean up the semantics of when #body can be called after
+ a request
* Other features as I think of them
diff --git a/lib/net2/http.rb b/lib/net2/http.rb
index f8fe19f..bead9d3 100644
--- a/lib/net2/http.rb
+++ b/lib/net2/http.rb
@@ -28,6 +28,17 @@
require "net2/backports"
end
+module URI
+ class Generic
+ unless URI::Generic.allocate.respond_to?(:hostname)
+ def hostname
+ v = self.host
+ /\A\[(.*)\]\z/ =~ v ? $1 : v
+ end
+ end
+ end
+end
+
module Net2 #:nodoc:
# :stopdoc:
@@ -452,12 +463,15 @@ def self.get(uri_or_host, path = nil, port = nil)
# print res.body
#
def self.get_response(uri_or_host, path = nil, port = nil, &block)
- if path
- host = uri_or_host
- else
+ if uri_or_host.respond_to?(:hostname)
host = uri_or_host.hostname
port = uri_or_host.port
path = uri_or_host.request_uri
+ elsif path
+ host = uri_or_host
+ else
+ uri = URI.parse(uri_or_host)
+ return get_response(uri, &block)
end
http = new(host, port || HTTP.default_port).start
diff --git a/test/http_test_base.rb b/test/http_test_base.rb
index 557145a..5906781 100644
--- a/test/http_test_base.rb
+++ b/test/http_test_base.rb
@@ -3,6 +3,12 @@ module TestNetHTTP_version_1_1_methods
def test_s_get
assert_equal $test_net_http_data,
Net::HTTP.get(config('host'), '/', config('port'))
+
+ assert_equal $test_net_http_data,
+ Net::HTTP.get("http://#{config('host')}:#{config('port')}/")
+
+ assert_equal $test_net_http_data,
+ Net::HTTP.get(URI.parse("http://#{config('host')}:#{config('port')}/"))
end
def test_head