lib/mechanize.rb in mechanize-2.4 vs lib/mechanize.rb in mechanize-2.5
- old
+ new
@@ -71,11 +71,11 @@
class Mechanize
##
# The version of Mechanize you are using.
- VERSION = '2.4'
+ VERSION = '2.5'
##
# Base mechanize error class
class Error < RuntimeError
@@ -261,20 +261,20 @@
# Callback which is invoked with the page that was added to history.
attr_accessor :history_added
##
- # A list of hooks to call after retrieving a response. Hooks are called with
- # the agent and the response returned.
+ # A list of hooks to call after retrieving a response. Hooks are called with
+ # the agent, the URI, the response, and the response body.
def post_connect_hooks
@agent.post_connect_hooks
end
##
- # A list of hooks to call before making a request. Hooks are called with
- # the agent and the request to be performed.
+ # A list of hooks to call before retrieving a response. Hooks are called
+ # with the agent, the URI, the response, and the response body.
def pre_connect_hooks
@agent.pre_connect_hooks
end
@@ -751,10 +751,32 @@
def idle_timeout= idle_timeout
@agent.idle_timeout = idle_timeout
end
##
+ # When set to true mechanize will ignore an EOF during chunked transfer
+ # encoding so long as at least one byte was received. Be careful when
+ # enabling this as it may cause data loss.
+ #
+ # Net::HTTP does not inform mechanize of where in the chunked stream the EOF
+ # occurred. Usually it is after the last-chunk but before the terminating
+ # CRLF (invalid termination) but it may occur earlier. In the second case
+ # your response body may be incomplete.
+
+ def ignore_bad_chunking
+ @agent.ignore_bad_chunking
+ end
+
+ ##
+ # When set to true mechanize will ignore an EOF during chunked transfer
+ # encoding. See ignore_bad_chunking for further details
+
+ def ignore_bad_chunking= ignore_bad_chunking
+ @agent.ignore_bad_chunking = ignore_bad_chunking
+ end
+
+ ##
# Are HTTP/1.1 keep-alive connections enabled?
def keep_alive
@agent.keep_alive
end
@@ -1217,10 +1239,12 @@
@history_added.call(page) if @history_added
end
end
+require 'mechanize/response_read_error'
+require 'mechanize/chunked_termination_error'
require 'mechanize/content_type_error'
require 'mechanize/cookie'
require 'mechanize/cookie_jar'
require 'mechanize/parser'
require 'mechanize/download'
@@ -1242,11 +1266,10 @@
require 'mechanize/monkey_patch'
require 'mechanize/pluggable_parsers'
require 'mechanize/redirect_limit_reached_error'
require 'mechanize/redirect_not_get_or_head_error'
require 'mechanize/response_code_error'
-require 'mechanize/unauthorized_error'
-require 'mechanize/response_read_error'
require 'mechanize/robots_disallowed_error'
+require 'mechanize/unauthorized_error'
require 'mechanize/unsupported_scheme_error'
require 'mechanize/util'