Mechanize 2.1 Released

mechanize version 2.1 has been released!

The Mechanize library is used for automating interaction with websites.
Mechanize automatically stores and sends cookies, follows redirects,
can follow links, and submit forms. Form fields can be populated and
submitted. Mechanize also keeps track of the sites that you have
visited as
a history.

=== 2.1 / 2011-12-20

  • Deprecations

    • Mechanize#get no longer accepts an options hash.
    • Mechanize::Util::to_native_charset has been removed.
  • Minor enhancements

    • Mechanize now depends on net-http-persistent 2.3+. This new version
      brings idle timeouts to help with the dreaded “too many connection
      issue when POSTing to a closed connection. Issue #123

    • SSL connections will be verified against the system certificate
      store by

    • Added Mechanize#retry_change_requests to allow mechanize to retry
      POST and
      other non-idempotent requests when you know it is safe to do so.

    • Mechanize can now stream files directly to disk without loading them
      memory first through Mechanize::Download, a pluggable parser for
      downloading files.

      All responses larger than Mechanize#max_file_buffer are downloaded
      to a
      Tempfile. For backwards compatibility Mechanize::File subclasses
      load the response body into memory.

      To force all unknown content types to download to disk instead of

      agent.pluggable_parser.default = Mechanize::Download

    • Added Mechanize#content_encoding_hooks which allow handling of
      non-standard content encodings like “agzip”. Patch #125 by

    • Added dom_class to elements and the element matcher like dom_id.
      #156 by Dan Hansen.

    • Added support for the HTML5 keygen form element. See Patch
      by Victor Costan.

    • Mechanize no longer follows meta refreshes that have no “url=” in
      content attribute to avoid infinite loops. To follow a meta refresh
      the same page set Mechanize#follow_meta_refresh_self to true. Issue
      by Jo Hund.

    • Updated ‘Mac Safari’ User-Agent alias to Safari 5.1.1. ‘Mac Safari
      4’ can
      be used for the old ‘Mac Safari’ alias.

    • When given multiple HTTP authentication options mechanize now picks
      strongest method.

    • Improvements to HTTP authorization:

      • mechanize raises Mechanize::UnathorizedError for 401 responses
        which is
        a sublcass of Mechanize::ResponseCodeError.
      • Added support for NTLM authentication, but this has not been
    • accepts attributes in a hash.

    • Mechanize::CookieJar#<<(cookie) (alias: add!) is added. Issue #139

    • Different mechanize instances may now have different loggers. Issue

    • Mechanize now accepts a proxy port as a service name or number
      Issue #167

  • Bug fixes

    • Mechanize now handles cookies just as most modern browsers do,
      roughly based on RFC 6265.
      • (which is invalid) is considered identical to
      • A cookie with is sent to
        as well as and
      • A cookie with domain=TLD (no dots) is accepted and sent if the
        host name is TLD, and rejected otherwise. To retain compatibility
        and convention, host/domain names starting with “local” are exempt
        from this rule.
      • A cookie with no domain attribute is only sent to the original
      • A cookie with an Effective TLD is rejected based on the public
        suffix list. (cf.
      • “Secure” cookies are not sent via non-https connection.
      • Subdomain match is not performed against an IP address.
      • It is recommended that you clear out existing cookie jars for
        regeneration because previously saved cookies may not have been
        parsed correctly.
    • Mechanize takes more care to avoid saving files with certain unsafe
      You should still take care not to use mechanize to save files
      into your home directory ($HOME). Issue #163.
    • Mechanize#cookie_jar= works again. Issue #126
    • The original Referer value persists on redirection. Issue #150
    • Do not send a referer on a Refresh header based redirection.
    • Fixed encoding error in tests when LANG=C. Patch #142 by jinschoi.
    • The order of items in a form submission now match the DOM order.
      #129 by kitamomonga
    • Fixed proxy example in EXAMPLE. Issue #146 by NielsKSchjoedt