- [RC::Cache] Check against
Numeric
instead ofFixnum
for Ruby 2.4 compatibility. - [RC::JsonResponse] Fix encoding issue when trying to remove BOM. See #24 and https://github.com/godfat/rest-core/commit/4123ca485ecc3b9d31749423f7039bfa1652a3a3 Thanks AshwiniDoddamaniFluke
Now the core functionality was extracted to a new gem, rest-builder.
rest-core from now on would just bundle middleware and some utilities.
Things like RC::Builder
should still work for the sake of compatibility,
but it's actually RestBuilder::Builder
underneath. Note that the core
concurrency facility was extracted to another new gem, promise_pool.
Since some parts were also rewritten, things might change somehow.
At least no public APIs were changed. It's completely compatible.
RC::Simple
was removed. There's no point for that.RC.id
was removed, in favour of:itself.to_proc
.- Include
RC::Middleware
would no longer includeRC
as well.
- We no longer
autoload
a lot of stuffs, rather, we just load it. - Previously, only when you try to peek the future, the callback would be
called. From now on, whenever the request is done, it would call the
callback regardless. However, if there's an exception, it won't be raised.
It would only raise whenever you peek it. An obvious difference for this
is the
RC::CommonLogger
. Previously since callback would only be called when you peek it, the time would be the difference from request done to you peeked it. From now on, it would just be how much time the request has been taken, regardless when you peek it.
- Client.defer would now raise an error if the block would raise an error.
- EventSource would now try to close the socket (actually, pipe from httpclient) if there's no data coming in in 35 seconds, (RC::EventSource::READ_WAIT) therefore we could reconnect in this case. This is mostly for rest-firebase, reference: CodementorIO/rest-firebase#8 We would surely need a way to configure this timeout rather than hard coding it for 35 seconds as different services could use different timeout. Thanks @volksport for investigating this.
- Added
RestCore::DalliExtension
for makingDalli::Client
walk and quad likeHash
so that you could pass it as a cache client toRestCore::Cache
.
- Instead of forcing to load
http/cookie_jar/hash_store.rb
, which is only available when http-cookie is available, we just initialize httpclient and throw it away. Hopefully this would be more compatible between versions.
- Fixed a potential deadlock or using a partially loaded stuff for
httpclient. We fixed this by requiring eagerly instead of loading
it lazily. The offender was: http-cookie:
http/cookie_jar/hash_store.rb
. httpclient could try to load this eagerly or just don't load it since we're not usingcookie_manager
anyway. The errors we've seen:NoMethodError: undefined method
implementation' for HTTP::CookieJar::AbstractStore:Class`ArgumentError: cookie store unavailable: :hash
- deadlock (because it's requiring it in a thread)
- Added
Client.defer
for doing arbitrary asynchronous tasks.
- JSON_REQUEST_METHOD was removed.
- GET/DELETE/HEAD/OPTIONS would no longer try to attach any payload.
- Introduced Middleware.has_payload? which would detect if the request should attach a payload or not.
- Removed changes shouldn't be made into JsonResponse. My bad.
I should
git stash
before making releases.
- Fixed a possible data race for thread pool when enqueuing very quickly.
- Fixed a regression where callback is not called for
RC::Cache
when cache is available.
- Fixed a regression where timeout is not properly handled for thread pool.
- Now callbacks would respect
RC::RESPONSE_KEY
. - Clear
Thread.current[:backtrace]
after done in thread pool to reduce memory footprint. - Fixed backtrace for exception raised in callbacks.
- Fixed some potential corner cases where errors are not properly handled when timeout happened.
- Ruby 2.2 compatibility.
RC::Builder
would now only deep copy arrays and hashes.RC::ErrorHandler
's only responsibility is now creating the exception. Raising the exceptions or passing it to the callback is now handled byRC::Client
instead. (Thanks Andrew Clunis, #6)- Since exceptions are raised by
RC::Client
now,RC::Timeout
would not raise any exception, but just hand over toRC::Client
. - Support for Ruby version < 1.9.2 is dropped.
- Reverted #10 because it caused the other encoding issue. (#12)
RC::Client#wait
andRC::Client.wait
would now properly wait forRC::FollowRedirect
RC::Event::CacheHit
is properly logged again.
-
Introduced
RC::Client#error_callback
which would get called for each exceptions raised. This is useful for monitoring and logging errors. -
Introduced
RC::Retry
which could retry the request upon certain errors. Specifymax_retries
for maximum times for retrying, andretry_exceptions
for which exceptions should be trying. Default is[IOError, SystemCallError]
-
Eliminated a few warnings when
-w
is used.
-
Handle errors for
RC::EventSource
more conservatively to avoid any potential deadlock. -
It would not deadlock even if logging failed.
- Removed rest-client support.
- Removed net-http-persistent support.
- Removed patch for old multi-json.
-
RC::JsonRequest
can now POST, PUT, or PATCH with a singlefalse
. -
Previously, we're not handling timeout correctly. We left all that to httpclient, and which would raise
HTTPClient::ConnectTimeoutError
andHTTPClient::ReceiveTimeoutError
. The problem is that connecting and receiving are counted separately. That means, if we have 30 seconds timeout, we might be ending up with 58 seconds requesting time, for 29 seconds connecting time and 29 seconds receiving time. Now it should probably interrupt the request in 30 seconds by handling this by ourselves with a timer thread in the background. The timer thread would be shut down automatically if there's no jobs left, and it would recreate the thread when there's a job comes in, keeping working until there's no jobs left.
- Introduced
RC::Timer.interval
which is the interval to check if there's a request timed out. The default interval is 1 second, which means it would check if there's a request timed out for every 1 second. This also means timeout with less than 1 second won't be accurate at all. You could decrease the value if you need timeout less than 1 second, or increase it if your timeout is far from 30 second by callingRC::Timer.interval = 5
.
-
RC::EventSource
would now properly reconnect for SystemCallError such asErrno::ECONNRESET
. -
It would now always emit a warning whenever there's an exception raised asynchronously.
-
All exceptions raised from a thread or thread pool would now have a proper backtrace. This was fixed by introducing
RC::Promise.backtrace
-
Introduced
RC::Promise.backtrace
. Using this in a callback could give you proper backtrace, comparing tocaller
would only give you the backtrace for current thread. -
Introduced
RC::Promise.set_backtrace
. Using this we could set exceptions with proper backtrace.
- Just use
File.join
forRC::DefaultSite
asFile::SEPARATOR
is universally/
and it would not try to raise exceptions for improperly encoded URI. #11 Man Vuong (@kidlab)
-
RC::Oauth1Header
would now properly encode queries in oauth_callback. rest-more#6 khoa nguyen (@khoan) -
Made all literal regular expression UTF-8 encoded, fixing encoding issue on JRuby. #10 Joe Chen (@joe1chen)
-
Now
RC::DefaultSite
would useURI.join
to prepend the default site, therefore eliminating duplicated / or missing /. #11 Man Vuong (@kidlab) -
Fixed deprecation warnings from
URI.escape
. Lin Jen-Shin (@godfat) -
Now we properly wait for the callback to be called to consider the request is done. Lin Jen-Shin (@godfat)
-
Removed
RC::Wrapper
. Apparently it's introducing more troubles than the benefit than it brings. Currently, onlyRC::Cache
is really using it, and now the old functionality is merged back toRC::Builder
. -
Therefore
RC::Cache
is no longer accepting a block. -
RC::Universal
is then updated accordingly to respect the newRC::Cache
.
-
Now
RC::DefaultQuery
,RC::DefaultPayload
, andRC::DefaultHeaders
work the same way. Previously they merge hashes slightly differently. -
Introduced
RC::Middleware#member=
in addition toRC::Middleware#member
. -
RC::JsonResponse would now strip the problematic UTF-8 BOM before parsing. This was introduced because Stackoverflow would return it. We also try to not raise any encoding issues here.
-
Introduced
RC::JsonResponse::ParseError
which would be a subclass ofRC::Json::ParseError
, and contain the original text before parsing. This should be great for debugging. For example, some servers might return HTML instead JSON, and we would like to read the HTML to learn more why they are doing this. -
Introduced
RC::ParseLink
utility for parsing web links described in RFC5988 -
Introduced
RC::Clash
which is a hash wrapper protecting you from getting nils from hashes. This is useful whenever we want to access a value deeply inside a hash. For example:json['a']['b']['c']['d']
would never fail due to nils. Note thatRC::Clash
is recursive. -
Introduced
RC::Smash
which is a hash wrapper protecting you from getting nils from hashes. This is useful whenever we want to access a value deeply inside a hash. Instead of using multiple layers of subscript operators, we try to use a "path" to specify which value we want. For example:json['a', 'b', 'c', 'd']
is the same asjson['a']['b']['c']['d']
but with protection from nils in the middle. Note thatRC:Smash
is not recursive. -
Introduced
RC::ClashResponse
which would wrap the response insideRC::Clash
. This is useful along withRC::JsonResponse
. -
Introduced
RC::SmashResponse
which would wrap the response insideRC::Smash
. This is useful along withRC::JsonResponse
. -
Introduced
RC::Client.shutdown
which is essentially the same asRC::Client.thread_pool.shutdown
andRC::Client.wait
. -
RC::ClashResponse
andRC::SmashResponse
is added intoRC::Universal
with{:clash_response => false, :smash_response => false}
by default. -
Introduced
RC::Promise#future_response
to allow you customize the behaviour of promises more easily. -
Introduced
RC::Promise.claim
to allow you pre-fill a promise. -
Introduced
RC::Promise#then
to allow you append a callback whenever the response is ready. The type should be:Env -> Response
-
Now
RC::Promise#inspect
would show REQUEST_URI instead of REQUEST_PATH, which should be easier to debug. -
Introduced
RC::ThreadPool#size
which is a short hand forRC::ThreadPool#workers.size
.
- Inheritance with
RC::Client
now works properly. - Now
RC::Cache
properly return cached headers. - Now
RC::Cache
would work more likeRC::Engine
, wrapping responses inside futures.
- Introduced
RC::Client.wait
along withRC::Client#wait
. It would collect all the promises from all instances of the client, so we could wait on all promises we're waiting. This would make writing graceful shutdown much easier. For example, we could have:at_exit{ RC::Universal.wait }
to wait on all requests from the universal client before exiting the process.
- Now that the second argument
key
inRC::Client#request
is replaced byRC::RESPONSE_KEY
passed in env. This would make it easier to use and more consistent internally. - Now RC::EventSource#onmessage would receive the event in the first argument, and the data in the second argument instead of a hash in the first argument.
- Added RC::REQUEST_URI in the env so that we could access the requesting URI easily.
- Added middleware RC::QueryResponse which could parse query in response.
- Added RC::Client.event_source_class which we could easily swap the class used for event_source. Used in Firebase client to parse data in JSON.
- Now methods in RC::EventSource would return itself so that we could chain callbacks.
- Added RC::EventSource#onreconnect callback to handle if we're going to reconnect automatically or not.
- RC::Config was extracted from rest-more, which could help us manage config files.
- RC::Json using JSON would now parse in quirks_mode, so that it could parse not only JSON but also a single value.
- We should never cache hijacked requests.
- Now we preserve payload and properly ignore query for RC::FollowRedirect.
Highlights:
- Hijack for streaming responses
- EventSource for SSE (server-sent events)
- Thread pool
- Keep-alive connections from httpclient
-
Since eventmachine is buggy, and fibers without eventmachine doesn't make too much sense, we have removed the support for eventmachine and fibers.
-
We also changed the default HTTP client from rest-client to httpclient. If you still want to use rest-client, switch it like this:
RC::Builder.default_engine = RC::RestClient
Be warned, we might remove rest-client support in the future.
-
RC::Client#options
would now return the headers instead of response body. -
Removed support for Ruby 1.8.7 without openssl installed.
-
RC::Future
is renamed toRC::Promise
, andRC::Future::Proxy
is renamed toRC::Promise::Future
.
-
HIJACK support, which is similar to Rack's HIJACK feature. If you're passing
{RC::HIJACK => true}
whenever making a request, rest-core would rather set theRC::RESPONSE_BODY
as an empty string, and setRC::RESPONSE_SOCKET
as a socket for the response. This is used forRC::EventSource
, and you could also use this for streaming the response. Note that this only works for default engine, httpclient. -
Introduce
RC::EventSource
. You could obtain the object viaRC::Client#event_source
, and then setuponopen
,onmessage
, andonerror
respectively, and then callRC::EventSource#start
to begin making the request, and receive the SSE (sever-sent events) from the server. This is used inRC::Firebase
from rest-more. -
Now we have thread pool support. We could set the pool size with:
RC::YourClient.pool_size = 10
and thread idle time with:RC::YourClient.pool_idle_time = 60
. By default,pool_size
is 0 which means we don't use a thread pool. Setting it to a negative number would mean do not spawn any threads, just make a blocking request.pool_idle_time
is default to 60, meaning an idle thread would be shut down after 60 seconds without being used. -
Since we're now using httpclient by default, we should also take the advantage of using keep-alive connections for the same host.
-
Now
RC::Middleware#fail
andRC::Middleware#log
could acceptnil
as an input, which would then do nothing. This could much simplify the code building middleware. -
Now we're using timers gem which should be less buggy from previous timeout.
- Remove support for Ruby < 1.9.2
- [
Client
] Fixed a bug where if we're using duplicated attributes.
- Fixed em-http-request support.
- [
Payload
] Now it is a class rather than a module. - [
Paylaod
] IntroducedPayload.generate_with_headers
. - [
Paylaod
] Give anil
if payload passing toPayload.generate
should not have any payload at all.
-
We no longer support Rails-like POST payload, like translating
{:foo => [1, 2]}
to'foo[]=1&foo[]=2'
. It would now be translated to'foo=1&foo=2'
. If you like'foo[]'
as the key, simply pass it as{'foo[]' => [1, 2]}
. -
This also applies to nested hashes like
{:foo => {:bar => 1}
. If you want that behaviour, just pass{'foo[bar]' => 1}
which would then be translated to'foo[bar]=1'
.
- [
Payload
] Now we could correctly support payload with "foo=1&foo=2". - [
Client
] Fix inspect spacing.
- [
Payload
] With this class introduced, replacing rest-client's own payload implementation, we could pass StringIO or other sockets as the payload body. This would also fix the issue that using the same key for different values as allowed in the spec. - [
EmHttpRequest
] Send payload as a file directly if it's a file. Buffer the payload into a tempfile if it's from a socket or a large StringIO. This should greatly reduce the memory usage as we don't build large Ruby strings in the memory. Streaming is not yet supported though. - [
Client
] Make inspect shorter. - [
Client
] Introduce Client#default_env - [
Middleware
] Introduce Middleware.percent_encode. - [
Middleware
] Introduce Middleware.contain_binary?.
- [
EmHttpRequest
] UseEM.schedule
to fix thread-safety issue.
-
Use
URI.escape(string, UNRESERVED)
for URI escaping instead ofCGI.escape
-
[
Defaults
] Userespond_to_missing?
instead ofrespond_to?
- [
Cache
] Fix cache with multiline response body. This might invalidate your existing cache.
- Don't walk into parent's constants in
RC.eagerload
. - Also rescue
NameError
inRC.eagerload
.
- Remove unnecessary
future.wrap
inEmHttpRequest
. - Introduce Future#callback_in_async.
- We would never double resume the fiber, so no need to rescue
FiberError
.
This is a major release which introduces some incompatible changes. This is intended to cleanup some internal implementation and introduce a new mechanism to handle multiple requests concurrently, avoiding needless block.
Before we go into detail, here's who can upgrade without changing anything, and who should make a few adjustments in their code:
-
If you're only using rest-more, e.g.
RC::Facebook
orRC::Twitter
, etc., you don't have to change anything. This won't affect rest-more users. (except that JsonDecode is renamed to JsonResponse, and json_decode is renamed to json_response.) -
If you're only using rest-core's built in middlewares to build your own clients, you don't have to change anything as well. All the hard works are done in rest-core. (except that ErrorHandler works a bit differently now. We'll talk about detail later.)
-
If you're building your own middlewares, then you are the ones who need to make changes.
RC::ASYNC
is changed to a flag to mean whether the callback should be called directly, or only after resuming from the future (fiber or thread). And now you have always to get the response fromyield
, that is, you're forced to pass a callback tocall
.This might be a bit user unfriendly at first glimpse, but it would much simplify the internal structure of rest-core, because in the middlewares, you don't have to worry if the user would pass a callback or not, branching everywhere to make it work both synchronously and asynchronously.
Also, the old fiber based asynchronous HTTP client is removed, in favor of the new future based approach. The new one is more like a superset of the old one, which have anything the old one can provide. Yet internally it works a lot differently. They are both synchronous to the outsides, but while the old one is also synchronous inside, the new one is asynchronous inside, just like the purely asynchronous HTTP client.
That is, internally, it's always asynchronously, and fiber/async didn't make much difference here now. This is also the reason why I removed the old fiber one. This would make the middleware implementation much easier, considering much fewer possible cases.
If you don't really understand what above does mean, then just remember, now we ask all middlewares work asynchronously. You have always to work with callbacks which passed along in
app.call(env){ |response| }
That's it.
So what's the most important improvement? From now on, we have only two
modes. One is callback mode, in which case env[ASYNC]
would be set, and
the callback would be called. No exception would be raised in this case.
If there's an exception, then it would be passed to the block instead.
The other mode, which is synchronous, is achieved by the futures. We have two different kinds of futures for now, one is thread based, and the other is fiber based. For RestClient, thread based future would be used. For EventMachine, depending on the context, if the future is created on the main thread, then it would assume it's also wrapped inside a fiber. Since, we can never block the event loop! If you're not calling it in a thread, you must call it in a fiber. But if you're calling it in a thread, then the thread based future would be picked. This is because otherwise it won't work well exchanging information around threads and fibers.
In short, rest-core would run concurrently in all contexts, archived by either threads or fibers depending on the context, and it would pick the right strategy for you.
You can see use-cases.rb for all possible use cases.
It's a bit outdated, but you can also checkout my blog post. rest-core 2.0 roadmap, thunk based response (p.s. now thunk is renamed to future)
-
[JsonDecode] is renamed to JsonResponse, and json_decode is also renamed to json_response.
-
[Json] Now you can use
Json.decode
andJson.encode
to parse and generate JSONs, instead ofJsonDecode.json_decode
. -
[Cache] Support for "cache.post" is removed.
-
[Cache] The cache key is changed accordingly to support cache for headers and HTTP status. If you don't have persistent cache, this doesn't matter.
-
[EmHttpRequestFiber] is removed in favor of
EmHttpRequest
-
cool.io support is removed.
-
You must provide a block to
app.call(env){ ... }
. -
Rename Wrapper#default_app to Wrapper#default_engine
-
The default engine is changed from
RestClient
toAuto
, which would be usingEmHttpRequest
under the context of a event loop, while useRestClient
in other context as before. -
RestCore.eagerload
is introduced to load all constants eagerly. You can use this before loading the application to avoid thread-safety issue in autoload. For the lazies. -
[JsonResponse] This is originally JsonDecode, and now we prefer multi_json first, yajl-ruby second, lastly json.
-
[JsonResponse] give JsonResponse a default header Accept: application/json, thanks @ayamomiji
-
[JsonRequest] This middleware would encode your payload into a JSON.
-
[CommonLogger] Now we log the request method as well.
-
[DefaultPayload] Accept arbitrary payload.
-
[DefaultQuery] Now before merging queries, converting every single key into a string. This allows you to use :symbols for default query.
-
[ErrorHandler] So now ErrorHandler is working differently. It would first try to see if
env[FAIL]
has any exception in it. If there is, then raise it. Otherwise it would call error_handler and expect it to generate an error object. If the error object is an exception, then raise it. If it's not, then it would merge it intoenv[FAIL]
. On the other hand, in the case of using callbacks instead of futures, it would pass the exception as theenv[RESPONSE_BODY]
instead. The reason is that you can't raise an exception asynchronously and handle it safely. -
[Cache] Now response headers and HTTP status are also cached.
-
[Cache] Not only GET requests are cached, HEAD and OPTIONS are cached too.
-
[Cache] The cache key is also respecting the request headers too. Suppose you're making a request with different Accept header.
-
[Client] Add Client#wait which would block until all requests for this particular client are done.
- [Middleware] Sort the query before generating the request URI, making sure the order is always the same.
- [Middleware] The middleware could have no members at all.
- [ParseQuery] The fallback function for the absence of Rack is fixed.
- [Auto] Only use EmHttpRequest if em-http-request is loaded, thanks @ayamomiji
- [Client]
client.head
now returns the headers instead of response body. It doesn't make sense to return the response body, because there's no such things in a HEAD request.
-
[Cache] The cache object you passed in would only need to respond to
[]
and[]=
. If the cache object accepts an:expires_in
option, then it must also respond tostore
, too. -
[Oauth1Header] Fixed a long standing bug that tilde (~) shouldn't be escaped. Many thanks to @brucehsu for discovering this!
- Some internal refactoring.
- Properly handle asynchronous timers for eventmachine and cool.io.
- [
Auto
] Check for eventmachine first instead of cool.io - [
EmHttpRequestFiber
] Also pass callback for errback - [
DefaultQuery
] Make default query to {} instead of nil
This is a very significant release. The most important change is now we support asynchronous requests, by either passing a callback block or using fibers in Ruby 1.9 to make the whole program still look synchronous.
Please read README.md or example for more detail.
-
[
Client
] Client#inspect is fixed for clients which do not have any attributes. -
[
Client
] HEAD, OPTIONS, and PATCH requests are added. For example:client = Client.new client.head('path') client.options('path') client.patch('path')
-
[
Client
] Now if you passed a block to eitherget
orpost
or other requests, the response would be returned to the block instead the caller. In this case, the return value ofget
orpost
would be the client itself. For example:client = Client.new client.get('path'){ |response| puts response.insepct }. get('math'){ |response| puts response.insepct }
-
[
RestClient
] Now all the response headers names are converted to upper cases and underscores (_). Also, if a header has only presented once, it would not be wrapped inside an array. This is more consistent with em-http-request, cool.io-http, and http_parser.rb -
[
RestClient
] From now on, the default HTTP client, i.e.RestClient
won't follow any redirect. To follow redirect, please useFollowRedirect
middleware. Two reasons. One is that the underlying HTTP client should be minimal. Another one is that a FollowRedirect middleware could be used for all HTTP clients. This would make it more consistent across all HTTP clients. -
[
RestClient
] Added a patch to avoid"123".to_i
returning200
, please see: https://github.com/archiloque/rest-client/pull/103 I would remove this once after this patch is merged. -
[
RestClient
] Added a patch to properly returning response whenever a redirect is happened. Please see: https://github.com/archiloque/rest-client/pull/118 I would remove this once after this patch is merged. -
[
FollowRedirect
] This middleware would follow the redirect. Pass :max_redirects for the maximum redirect times. For example:Client = RestCore::Builder.client do use FollowRedirect, 2 # default :max_redirects end client = Client.new client.get('path', {}, :max_redirects => 5)
-
[
Middleware
] AddedMiddleware#run
which can return the underlying HTTP client, if you need to know the underlying HTTP client can support asynchronous requests or not. -
[
Cache
] Now it's asynchrony-aware. -
[
CommonLogger
] Now it's asynchrony-aware. -
[
ErrorDetector
] Now it's asynchrony-aware. -
[
ErrorHandler
] Now it's asynchrony-aware. -
[
JsonDecode
] Now it's asynchrony-aware. -
[
Timeout
] Now it's asynchrony-aware. -
[
Universal
]FollowRedirect
middleware is added. -
[
Universal
]Defaults
middleware is removed. -
Added
RestCore::ASYNC
which should be the callback function which is called whenever the response is available. It's similar to Rack's async.callback. -
Added
RestCore::TIMER
which is only used in Timeout middleware. We need this to disable timer whenever the response is back. -
[
EmHttpRequestAsync
] This HTTP client accepts a block to make asynchronous HTTP requests via em-http-request gem. -
[
EmHttpRequestFiber
] This HTTP client would make asynchronous HTTP requests with em-http-request but also wrapped inside a fiber, so that it looks synchronous to the program who calls it. -
[
EmHttpRequest
] This HTTP client would would useEmHttpRequestAsync
if a block (RestCore::ASYNC
) is passed, otherwise useEmHttpRequestFiber
. -
[
CoolioAsync
] This HTTP client is basically the same asEmHttpRequestAsync
, but using cool.io-http instead of em-http-request. -
[
CoolioFiber
] This HTTP client is basically the same asEmHttpRequestFiber
, but using cool.io-http instead of em-http-request. -
[
Coolio
] This HTTP client is basically the same asEmHttpRequest
, but using cool.io-http instead of em-http-request. -
[
Auto
] This HTTP client would auto-select a suitable client. Under eventmachine, it would useEmHttpRequest
. Under cool.io, it would useCoolio
. Otherwise, it would useRestClient
.
-
[
DefaultPayload
] This middleware allows you to have default payload for POST and PUT requests. -
[
Client
] Nowlighten
would give all Unserializable to nil instead of false
- [
ErrorDetector
] Now it would do nothing instead of crashing if there's no any error_detector.
- [
Wrapper
] IntroducingWrapper.default_app
(alsoBuilder.default_app
) which you can change the default app fromRestClient
to other HTTP clients.
-
[
OAuth1Header
] Correctly handle the signature when it comes to multipart requests. -
[
ErrorDetectorHttp
] Fixed argument error upon callinglighten
for clients using this middleware. (e.g. rest-more's Twitter client)
Changes are mostly related to OAuth.
-
[
OAuth1Header
]callback
is renamed tooauth_callback
-
[
OAuth1Header
]verifier
is renamed tooauth_verifier
-
[
Oauth2Header
] The first argument is changed fromaccess_token
toaccess_token_type
. Previously, the access_token_type is "OAuth" which is used in Mixi. But mostly, we might want to use "Bearer" (according to OAuth 2.0 spec) Argument for the access_token is changed to the second argument. -
[
Defaults
] Now we're no longer callcall
for any default values. That is, if you're using this:use s::Defaults, :data => lambda{{}}
that would break. Previously, this middleware would callcall
on the lambda so thatdata
is default to a newly created hash. Now, it would merely be default to the lambda. To make it work as before, please definedef default_data; {}; end
in the client directly. Please seeOAuth1Client
as an example.
-
[
AuthBasic
] Added a new middleware which could do basic authentication. -
[
OAuth1Header
] Introduceddata
which is a hash and is used to store tokens and other information sent from authorization servers. -
[
ClientOauth1
] Nowauthorize_url!
accepts opts which you can passauthorize_url!(:oauth_callback => 'http://localhost/callback')
. -
[
ClientOauth1
] Introducedauthorize_url
which would not try to ask for a request token, instead, it would use the current token as the request token. If you don't understand what does this mean, then keep usingauthorize_url!
, which would call this underneath. -
[
ClientOauth1
] Introducedauthorized?
-
[
ClientOauth1
] Now it would setdata['authorized'] = 'true'
whenauthorize!
is called, and it is also used to check if we're authorized or not inauthorized?
-
[
ClientOauth1
] Introduceddata_json
anddata_json=
which allow you to serialize and deserializedata
with JSON along with asig
to check if it hasn't been changed. You can put this into browser cookie. Because of thesig
, you would know if the user changed something in data without usingconsumer_secret
to generate a correct sig corresponded to the data. -
[
ClientOauth1
] Introducedoauth_token
,oauth_token=
,oauth_token_secret
,oauth_token_secret=
,oauth_callback
, andoauth_callback=
which take the advantage ofdata
. -
[
ClientOauth1
] Introduceddefault_data
which is a hash.
- Moved rib-rest-core to rest-more
- Moved
RestCore::Config
to rest-more - Renamed
RestCore::Vendor
toRestCore::ParseQuery
From now on, prebuilt clients such as RC::Facebook
, RC::Twitter
and
others are moved to rest-more. Since bundler didn't like cyclic
dependency, so rest-core is not depending on rest-more. Please install
rest-more if you want to use them.
-
[dry] Now
RestCore::Ask
is renamed toRestCore::Dry
for better understanding. Thanks miaout17 -
[client] Now
request
method takes an env and an app to make requests, instead of a weird requests array. -
[client] Now if you really want to disable something, for example, disabling cache when the default cache is
Rails.cache
, you'll need to passfalse
instead ofnil
. This is becausenil
stands for using defaults in rest-core. -
[client] Defaults priorities are changed to: per-request > instance variable > class defaults > middleware defaults See test_client.rb for more detailed definition. If you don't understand this, don't worry, since then this won't affect you.
-
[client] Introduced a new method
request_full
which is exactly the same asrequest
but also returns various information from the app, includingRESPONSE_STATUS
andRESPONSE_HEADERS
-
[client] Removed various unused, untested, undocumented legacy from rest-graph.
-
[error] Introduced
RestCore::Error
which is the base class for all exceptions raised by rest-core -
[builder] Now
RestCore::Builder.default_app
is the default app which would be used for building clients without setting an app. By default, it'sRestClient
, but you can change it if you like. -
[builder] It no longer builds a @wrapped app. If you don't understand this, then this does nothing for you. It's an internal change. (or bug fix)
-
[wrapper] Now
RestCore::Wrapper.default_app
is the default app which would be used for wrapping middlewares without setting an app. By default, it'sDry
, but you can change it if you like. -
[wrapped] Fixed a bug that force middlewares to implement
members
method, which should be optional. Thanks miaout17 -
[facebook][rails_util] Now default cache is
Rails.cache
instead of nil -
[simple] Added a Simple client, which only wraps RestClient
-
[univeral] Added an Universal client, which could be used for anything
-
[flurry] Added a Flurry client, along with its
Flurry::RailsUtil
-
[mixi] Added a Mixi client
-
[bypass] Added a Bypass middleware which does nothing but passing env
-
[oauth2_header] OAuth2Header is a middleware which would pass access_token in header instead of in query string.
-
[common_logger] nil object would no longer be logged
-
[json_decode] Do nothing if we are being asked for env (dry mode)
-
[cache] Now default
:expires_in
is 600 down from 3600 -
[middleware] Now not only query values would be escaped, but also keys.
-
[rib-rest-core] Introduced an interactive shell. You'll need rib to run this:
rib rest-core
. It is using an universal client to access arbitrary websites.
-
[facebook] RestGraph is Facebook now.
-
[facebook] Facebook::RailsUtil is imported from rest-graph
-
[facebook] Use json_decode instead of auto_decode as rest-graph
-
[facebook] No longer calls URI.encode on Facebook broken URL
-
[twitter] Fixed opts in Twitter#tweet
-
[twitter] Introduced Twitter::Error instead of RuntimeError!
-
[twitter] By default log nothing
-
[rest-core] We no longer explicitly depends on Rack
-
[rest-core] Added a shorthand RC to access RestCore
-
[rest-core] Eliminated a lot of warnings
-
[cache] All clients no longer have default hash cache
-
[oauth2_query] Now we always use the term "access_token"
-
[config] Now Config#load and Config#load_for_rails take namespace e.g. rest-core.yaml:
development: facebook: app_id: 123 twitter: consumer_key: abc
- Adding rack as a runtime dependency for now. To reduce frustration for new comer...
- Adding rest-client as a runtime dependency for now. In the future, it should be taken out because of multiple selectable HTTP client backend (rest-core app).
- [twitter] Fixed default site
- [twitter] Now Twitter#tweet accepts a 2nd argument to upload an image
- [oauth1_header] Fixed a bug for multipart posting. Since Rails' uploaded file is not an IO object, so we can't only test against IO object, but also read method.
- First serious release!