godfat / rest-core Goto Github PK
View Code? Open in Web Editor NEWVarious rest-builder middleware for building REST clients.
License: Apache License 2.0
Various rest-builder middleware for building REST clients.
License: Apache License 2.0
The current engine returns response content in the body. When content size is large (hundreds of MB), this content will be held in memory.
When there are multiple threads fetching large dataset, it can crash boxes with low memory.
Can we have an engine that returns IO object to response content?
# musing with possible API
RC::Universal.new(
'response_body' => 'io', # defaults to response content when unspecified, which is the current behavior
'site' => 'http://large.size.api/',
).get('/')
``
I have some problems when json with strange things (†for example) is returned from API:
RestCore: spent 0.050203 Requested GET http://localhost:3000/projects/matches?num=1&project_ids=54371a58a760550d1d0000b8%2C54335519a760550d1d0000a4%2C54212245a760550d1d000050&threshold=0
/Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/middleware/json_response.rb:33:in `sub': incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/middleware/json_response.rb:33:in `process'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/middleware/json_response.rb:26:in `block in call'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/middleware/common_logger.rb:13:in `block in call'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/middleware/cache.rb:35:in `block in app_call'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:146:in `call'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:146:in `block in callback'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:140:in `each'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:140:in `inject'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:140:in `callback'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:79:in `yield'
from /Users/david/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:14:in `method_missing'
from /Users/david/Projects/makersqr/test_suite.rb:22:in `run'
from /Users/david/Projects/makersqr/test.thor:6:in `local'
Anything I can do about this?
Client:
MatchingApiClient = RC::Builder.client do
use RC::DefaultSite , ENVIRONMENTS[:producton]
use RC::DefaultQuery, { threshold: 0 }
use RC::JsonRequest, true
use RC::JsonResponse, true
use RC::CommonLogger, method(:puts)
use RC::Cache , nil, 3600
end
is this on the roadmap? or ftp is already supported but undocumented currently?
I have set some scripts to run via cron and I see a lot of stuck ruby processes now. I inspected with strace, it says: futex(0x7f8af4cf6eac, FUTEX_WAIT_PRIVATE, 1, NULL
and with gdb I get this stack trace:
/home/david/.rbenv/versions/2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:61:in `sysread'
/home/david/.rbenv/versions/2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:61:in `fill_rbuff'
/home/david/.rbenv/versions/2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:208:in `gets'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient/session.rb:352:in `gets'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient/session.rb:881:in `block in parse_header'
/home/david/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
/home/david/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:127:in `timeout'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient/session.rb:877:in `parse_header'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient/session.rb:860:in `read_header'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient/session.rb:667:in `get_header'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient.rb:1202:in `do_get_header'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient.rb:1151:in `do_get_block'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient.rb:952:in `block in do_request'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient.rb:1046:in `protect_keep_alive_disconnected'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient.rb:951:in `do_request'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpclient-2.5.2/lib/httpclient.rb:813:in `request'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/engine/http-client.rb:27:in `request_sync'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/engine/http-client.rb:17:in `request'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/engine.rb:11:in `block in call'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:65:in `call'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:65:in `block (2 levels) in defer'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:128:in `block in synchronized_yield'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:128:in `synchronize'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:128:in `synchronized_yield'
/home/david/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-core-3.3.2/lib/rest-core/promise.rb:65:in `block in defer'
What could be causing this? Thank you
With the following middleware:
use RC::ErrorHandler , lambda {|env| RuntimeError.new(env[RC::RESPONSE_BODY]['message']) }
use RC::ErrorDetector , lambda {|env| env[RC::RESPONSE_BODY]['status'] != 'ok'}
use RC::ErrorDetectorHttp
use RC::JsonResponse , true
and a request that returns a non-success http status code returning an html error page, JsonResponse can't parse the response.
Moving the JsonResponse middleware to before the ErrorHandler (not just ErrorDetectorHttp) solves this problem, but then the ErrorDetector and ErrorHandler can't be used because at that moment the body hasn't been parsed yet.
Any idea how to solve this nicely?
(Somewhat similar to #8.)
Is it possible for me to listen for when a child is added in my firebase with this library? If so, how would you do it?
I am trying to send a DELETE request with a REQUEST_PAYLOAD that carries list of ids in JSON format which gets ignored from the web services. The same request used to work with a very old version of rest-core '2.1.2'
Currently i am using 'rest-core', '4.0.1' with ruby 2.3.3 on rails 5.0.0 in which it fails.
Could this be an issue with httpclient?
There is a "problem" when a Future refers to a nil result (or false). The Future will seem like it is a NilClass object since Future is a BasicObject and will proxy almost everything to NilClass. However Future is truthy and not falsey like NilClass. This can be a huge pain to debug and figure out.
Maybe I can recommend some possible solutions. Please note I don't know this library very well.
If possible it would be better to use SimpleDelegator from standard library to avoid this problem.
Using - ruby - 2.4.1
rails - 5.0.0
rest-core - 4.0.0
Full Trace of the error :
/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/cache.rb:71: warning: constant ::Fixnum is deprecated
RestBuilder::Promise: ERROR: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)
from ["/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/json_response.rb:33:in `sub'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/json_response.rb:33:in `process'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/json_response.rb:26:in `block in call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/common_logger.rb:13:in `block in call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/cache.rb:34:in `block in app_call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in `block in resolve'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in `each'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in `inject'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in `resolve'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:109:in `fulfilling'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:84:in `block in fulfill'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:84:in `synchronize'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:84:in `fulfill'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:136:in `protected_yield'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:49:in `block in defer'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-builder-0.9.1/lib/rest-builder/engine.rb:28:in `call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/auth_basic.rb:10:in `call'",
"/Users/ashwini/no-rocket-science/sw-web/lib/fluke/token.rb:24:in `call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/cache.rb:29:in `app_call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/cache.rb:25:in `call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/common_logger.rb:12:in `call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/json_response.rb:24:in `call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-core-4.0.0/lib/rest-core/middleware/default_site.rb:14:in `call'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rest-builder-0.9.1/lib/rest-builder/client.rb:168:in `request_full'",
"/Users/ashwini/no-rocket-science/sw-web/lib/fluke/client/client.rb:136:in `do_request'",
"/Users/ashwini/no-rocket-science/sw-web/lib/fluke/client/client.rb:81:in `get'",
"/Users/ashwini/no-rocket-science/sw-web/lib/fluke/client/constants_api.rb:46:in `measurement_types'",
"/Users/ashwini/no-rocket-science/sw-web/config/initializers/fluke_global.rb:121:in `<top (required)>'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:287:in `load'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:287:in `block in load'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:287:in `load'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/engine.rb:648:in `block in load_config_initializer'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/notifications.rb:166:in `instrument'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/engine.rb:647:in `load_config_initializer'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/engine.rb:611:in `each'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/engine.rb:611:in `block in <class:Engine>'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `instance_exec'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `run'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/initializable.rb:44:in `each'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/initializable.rb:44:in `tsort_each_child'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:415:in `call'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `call'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'",
"/Users/ashwini/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/initializable.rb:54:in `run_initializers'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/application.rb:352:in `initialize!'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/railtie.rb:193:in `public_send'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/railtie.rb:193:in `method_missing'",
"/Users/ashwini/no-rocket-science/sw-web/config/environment.rb:5:in `<top (required)>'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `block in require'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'",
"/Users/ashwini/no-rocket-science/sw-web/config.ru:3:in `block in <main>'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'",
"/Users/ashwini/no-rocket-science/sw-web/config.ru:in `new'",
"/Users/ashwini/no-rocket-science/sw-web/config.ru:in `<main>'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands/server.rb:59:in `app'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands/server.rb:124:in `log_to_stdout'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands/server.rb:77:in `start'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:90:in `block in server'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `tap'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `server'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'",
"/Users/ashwini/.rvm/gems/ruby-2.4.1/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'",
"bin/rails:9:in `require'", "bin/rails:9:in `<main>'"]
Hi Godfat,
It's good to see this project still going strong. The event source example looks pretty similar to a lot of the chat example they have with web sockets.
What is your thought on getting streaming response on the web these days? Some web API provides both WS and Rest API these days.
Lately I realized that #25 somehow breaks https://github.com/CodementorIO/rest-firebase
Where previously if we're deleting something, it would just make the DELETE request without any payload. Now it would always append {}
as the payload.
This probably doesn't really hurt, as the server could simply ignore it. However it's a bit weird even if we don't specify anything, it would attach that, and moreover, it seems there's no way to disable this behaviour unless we disable JsonRequest
by passing :json_request => false
for the delete request.
I am thinking perhaps the default payload should actually be something like UNSPECIFIED
and whenever we saw that, we know we don't intend to attach any payload. However this could break a number of middleware which they might just assume a payload should be a hash like object.
I have been pondering about this issue for a while, and don't know the answer yet.
@AshwiniDoddamaniFluke Any thoughts? It would be great if you could give me some input. For example, if the default payload changed from {}
to UNSPECIFIED
(where it's defined as Object.new
), would this break your application?
Can we add support for ohler55/oj?
How would we ignore errors from RC::JsonResponse on Redirect?
e.g.
curl http://some.json.api/
=>
HTTP/1.1 301 Moved Permanently
Location: https://some.json.api/
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved Permanently</TITLE></HEAD><BODY>
<H1>30 Moved</H1>
The document has moved
<A HREF="https://some.json.api/">here</A>.
</BODY></HTML>
RC::Universal.new('site' => 'http://some.json.api/', 'json_response' => true).get('/')
=> RestCore::JsonResponse::ParseError: 399: unexpected token at ...
`RestCore: spent 7.070209 Requested GET https://streaming.preprod.connect.fluke.com/iot-service/history/reports/download/b9498f13-62cf-44ba-9a1e-1eb2b4444d22?deviceType=fc3540&frequency=TWELVE_HOUR&sessionStartTime=1499763413506&from=1501668000000&reportType=xlsx&requesterTimeZone=GMT%2B0530&app_platform=website&app_vers=272
"\xAD" from ASCII-8BIT to UTF-8
/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:34:in encode' /.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:34:in
to_json'
/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:34:in to_json' /.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/json/encoding.rb:55:in
to_json'
/.rvm/gems/ruby-2.3.3/gems/json-1.8.6/lib/json/common.rb:223:in generate' /.rvm/gems/ruby-2.3.3/gems/json-1.8.6/lib/json/common.rb:223:in
generate'
/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/json/encoding.rb:99:in stringify' /.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/json/encoding.rb:33:in
encode'
/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/json/encoding.rb:20:in encode' /.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:37:in
to_json'
/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.0/lib/action_controller/metal/renderers.rb:159:in block in <module:Renderers>' /.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.0/lib/action_controller/metal/renderers.rb:152:in
block in _render_to_body_with_renderer'
/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/set.rb:306:in each_key' /.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/set.rb:306:in
each'
/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.0/lib/action_controller/metal/renderers.rb:148:in _render_to_body_with_renderer' /.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.0/lib/action_controller/metal/renderers.rb:144:in
render_to_body'
/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.0/lib/abstract_controller/rendering.rb:26:in render' /.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.0/lib/action_controller/metal/rendering.rb:36:in
render'
/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:44:in block (2 levels) in render' /.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0/lib/active_support/core_ext/benchmark.rb:12:in
block in ms'`
I'd like to communicate with a test server that has a self-signed SSL certificate for HTTPS. Where can I set the SSL options to provide the CA or set verification to none?
I can find the HTTPClient in http-client.rb, but I don't quite see how to access it from a middleware, for example, to access its ssl_options member.
require "rest-core"
SillyClient = RC::Builder.client do
use RC::JsonResponse, true
# localhost is not listening on 3141, so the IP stack just returns RST
# instantly
use RC::DefaultSite, "http://localhost:3141/"
use RC::CommonLogger, method(:puts)
end
myclient = SillyClient.new
myclient.get("whatever").to_s # -> gives me nil, no exception thrown.
Thank you!
While working on Ruby 2.4.0 and using rest-core 3.0.0 I am not able to build client as per the document goes.
=> YourClient
2.4.0 :008 > YourClient.new
=> #<struct YourClient site=nil, json_response=nil, log_method=nil, cache=nil, expires_in=nil>
Getting response as above
Please guide me on how to resolve this.
Thanks in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.