RESTClient v2.0.0 Release Notes
Release Date: 2016-07-02 // over 7 years ago-
๐ This release is largely API compatible, but makes several breaking changes.
- โฌ๏ธ Drop support for Ruby 1.9
- ๐ Allow mime-types as new as 3.x (requires ruby 2.0)
- Respect Content-Type charset header provided by server. Previously,
rest-client would not override the string encoding chosen by Net::HTTP. Now
responses that specify a charset will yield a body string in that encoding.
For example,
Content-Type: text/plain; charset=EUC-JP
will return a String encoded withEncoding::EUC_JP
. (#361) - ๐ Change exceptions raised on request timeout. Instead of
RestClient::RequestTimeout
(which is still used for HTTP 408), network timeouts will now raise eitherRestClient::Exceptions::ReadTimeout
orRestClient::Exceptions::OpenTimeout
, both of which inherit fromRestClient::Exceptions::Timeout
. For backwards compatibility, this still inherits fromRestClient::RequestTimeout
so existing uses will still work. This may change in a future major release. These new timeout classes also make the original wrapped exception available as#original_exception
. - Unify request exceptions under
RestClient::RequestFailed
, which still inherits fromExceptionWithResponse
. Previously, HTTP 304, 401, and 404 inherited directly fromExceptionWithResponse
rather than fromRequestFailed
. Now all HTTP status code exceptions inherit from both. - โฑ Rename the
:timeout
request option to:read_timeout
. When:timeout
is passed, now set both:read_timeout
and:open_timeout
. - Change default HTTP Accept header to
*/*
- 0๏ธโฃ Use a more descriptive User-Agent header by default
- โฌ๏ธ Drop RC4-MD5 from default cipher list
- Only prepend http:// to URIs without a scheme
- ๐ Fix some support for using IPv6 addresses in URLs (still affected by Ruby 2.0+ bug https://bugs.ruby-lang.org/issues/9129, with the fix expected to be backported to 2.0 and 2.1)
Response
objects are now a subclass ofString
rather than aString
that mixes in the response functionality. Most of the methods remain unchanged, but this makes it much easier to understand what is happening when you look at a RestClient response object. There are a few additional changes:- Response objects now implement
.inspect
to make this distinction clearer. Response#to_i
will now behave likeString#to_i
instead of returning the HTTP response code, which was very surprising behavior.Response#body
and#to_s
will now return a trueString
object rather than self. Previously there was no easy way to get the trueString
response instead of the Frankenstein response string object with AbstractResponse mixed in.- Response objects no longer accept an extra request args hash, but instead access request args directly from the request object, which reduces confusion and duplication.
- Response objects now implement
- ๐ Handle multiple HTTP response headers with the same name (except for Set-Cookie, which is special) by joining the values with a comma space, compliant with RFC 7230
- ๐ Rewrite cookie support to be much smarter and to use cookie jars consistently
for requests, responses, and redirection in order to resolve long-standing
complaints about the previously broken behavior: (#498)
- The
:cookies
option may now be a Hash of Strings, an Array of HTTP::Cookie objects, or a full HTTP::CookieJar. - Add
RestClient::Request#cookie_jar
and reimplementRequest#cookies
to be a wrapper around the cookie jar. - Still support passing the
:cookies
option in the headers hash, but now raise ArgumentError if that option is also passed toRequest#initialize
. - Warn if both
:cookies
and aCookie
header are supplied. - Use the
Request#cookie_jar
as the basis forResponse#cookie_jar
, creating a copy of the jar and adding any newly received cookies. - When following redirection, also use this same strategy so that cookies from the original request are carried through in a standards-compliant way by the cookie jar.
- The
- Don't set basic auth header if explicit
Authorization
header is specified - โ Add
:proxy
option to requests, which can be used for thread-safe per-request proxy configuration, overridingRestClient.proxy
- ๐ Allow overriding
ENV['http_proxy']
to disable proxies by settingRestClient.proxy
to a falsey value. Previously there was no way in Ruby 2.x to turn off a proxy specified in the environment without changingENV
. - โ Add actual support for streaming request payloads. Previously rest-client
would call
.to_s
even on RestClient::Payload::Streamed objects. Instead, treat any object that responds to.read
as a streaming payload and pass it through to.body_stream=
on the Net:HTTP object. This massively reduces the memory required for large file uploads. - ๐ Changes to redirection behavior: (#381, #484)
- Remove
RestClient::MaxRedirectsReached
in favor of the normalExceptionWithResponse
subclasses. This makes the response accessible on the exception object as.response
, making it possible for callers to tell what has actually happened when the redirect limit is reached. - When following HTTP redirection, store a list of each previous response on
the response object as
.history
. This makes it possible to access the original response headers and body before the redirection was followed. - Follow redirection consistently, regardless of whether the HTTP method was passed as a symbol or string. Under the hood rest-client now normalizes the HTTP request method to a lowercase string.
- Remove
- Add
:before_execution_proc
option toRestClient::Request
. This makes it possible to add procs likeRestClient.add_before_execution_proc
to a single request without global state. - โ Run tests on Travis's beta OS X support.
- ๐ Make
Request#transmit
a private method, along with a few others. - ๐จ Refactor URI parsing to happen earlier, in Request initialization.
- ๐ Improve consistency and functionality of complex URL parameter handling:
- When adding URL params, handle URLs that already contain params.
- Add new convention for handling URL params containing deeply nested arrays and hashes, unify handling of null/empty values, and use the same code for GET and POST params. (#437)
- Add the RestClient::ParamsArray class, a simple array-like container that can be used to pass multiple keys with same name or keys where the ordering is significant.
- โ Add a few more exception classes for obscure HTTP status codes.
- Multipart: use a much more robust multipart boundary with greater entropy.
- ๐ฐ Make
RestClient::Payload::Base#inspect
stop pretending to be a String. - Add
Request#redacted_uri
andRequest#redacted_url
to display the URI with any password redacted.