riddl 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9151bbe616252bba8dcaa453d7a80c8ee302709ead1a491cf5d6b271674f6068
4
- data.tar.gz: b5cc9a75e847d2177dcc8fe1b3f5a293dc4194a659801dcbe87d117d452fd42f
3
+ metadata.gz: 28692624877cae67118d788e232ffad0707e98f685257ae38661a50235cc2e19
4
+ data.tar.gz: 773269607873f5d8153cb92accdb3bbcd058109c3ea00f1704807d5b5496d8af
5
5
  SHA512:
6
- metadata.gz: d730da18c9408ce79d10d2836e51f4ac961e95bb4ba6fa8d26025cb7b6840fe2a307312bac4e6129073e06d3532ce9a24ac27bfd4a1ed613fa9a7977e766d7a5
7
- data.tar.gz: 965872cb5818403abb37f070115f2bd9e0d3c5632e4a6f639097f879f219f9d725a88ad912318d6decba8d333016ec3814409bd10ea6efa23013c5ca8e55ba26
6
+ metadata.gz: d4ac230888df9ae43b840f407764ee293d6d1ddfe9c242ea9fa5e850c8b455a1722a9a1da6ba675710b310e9fa10804d67b037424799e671b4ef6b2cd299bd93
7
+ data.tar.gz: 5bb88e50380fcc18206f5d0c021cbeac4c7c473e97e94c221af6880baa9aac20b8f39057e042127fd2cce4e8157710eadbf630174f8a3caa426d7c1f5f083c31
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  All code in this package is provided under the LGPL license.
2
- Please read the file COPYING.
2
+ Please read the file LICENSE.
3
3
 
4
4
  For all running services (unless they are started in production mode):
5
5
 
@@ -2,15 +2,15 @@
2
2
  This file is part of CPEE.
3
3
 
4
4
  CPEE is free software: you can redistribute it and/or modify it under the terms
5
- of the GNU General Public License as published by the Free Software Foundation,
5
+ of the GNU Lesser General Public License as published by the Free Software Foundation,
6
6
  either version 3 of the License, or (at your option) any later version.
7
7
 
8
8
  CPEE is distributed in the hope that it will be useful, but WITHOUT ANY
9
9
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10
- PARTICULAR PURPOSE. See the GNU General Public License for more details.
10
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
11
11
 
12
- You should have received a copy of the GNU General Public License along with
13
- CPEE (file COPYING in the main directory). If not, see
12
+ You should have received a copy of the GNU Lesser General Public License along with
13
+ CPEE (file LICENSE in the main directory). If not, see
14
14
  <http://www.gnu.org/licenses/>.
15
15
  -->
16
16
 
@@ -291,10 +291,11 @@ unless Module.constants.include?('CLIENT_INCLUDED')
291
291
  qparams = extract_qparams(parameters,riddl_method.downcase)
292
292
 
293
293
  response = nil
294
+ ignore = @options[:ignore_response] ? true : false # status and headers only, the body is discarded while receiving
294
295
  if @wrapper.nil? || @wrapper.description? || (@wrapper.declaration? && !@base.nil?)
295
- status, response, response_headers = make_request(@base + @rpath,riddl_method,parameters,headers,qparams,simulate,riddl_message && riddl_message.out ? true : false)
296
+ status, response, response_headers = make_request(@base + @rpath,riddl_method,parameters,headers,qparams,simulate,riddl_message && riddl_message.out ? true : false,ignore)
296
297
  return response if simulate
297
- if !@wrapper.nil? && status >= 200 && status < 300
298
+ if !@wrapper.nil? && !ignore && status >= 200 && status < 300
298
299
  unless @wrapper.check_message(response,response_headers,riddl_message.out)
299
300
  raise OutputError, "Not a valid output from service."
300
301
  end
@@ -302,9 +303,9 @@ unless Module.constants.include?('CLIENT_INCLUDED')
302
303
  elsif !@wrapper.nil? && @base.nil? && @wrapper.declaration?
303
304
  headers['RIDDL-DECLARATION-PATH'] = @rpath
304
305
  if !riddl_message.route?
305
- status, response, response_headers = make_request(riddl_message.interface.real_url(@rpath,@base),riddl_method,parameters,headers,qparams,simulate,riddl_message && riddl_message.out ? true : false)
306
+ status, response, response_headers = make_request(riddl_message.interface.real_url(@rpath,@base),riddl_method,parameters,headers,qparams,simulate,riddl_message && riddl_message.out ? true : false,ignore)
306
307
  return response if simulate
307
- if status >= 200 && status < 300
308
+ if !ignore && status >= 200 && status < 300
308
309
  unless @wrapper.check_message(response,response_headers,riddl_message.out)
309
310
  raise OutputError, "Not a valid output from service."
310
311
  end
@@ -314,13 +315,14 @@ unless Module.constants.include?('CLIENT_INCLUDED')
314
315
  th = headers
315
316
  tq = qparams
316
317
  riddl_message.route.each do |m|
317
- if m == riddl_message.route.last
318
- status, response, response_headers = make_request(m.interface.real_url(@rpath,@base),riddl_method,tp,th,tq,simulate,riddl_message && riddl_message.out ? true : false)
318
+ last = (m == riddl_message.route.last) # intermediate responses are the input of the next hop, never ignore them
319
+ if last
320
+ status, response, response_headers = make_request(m.interface.real_url(@rpath,@base),riddl_method,tp,th,tq,simulate,riddl_message && riddl_message.out ? true : false,ignore)
319
321
  else
320
322
  status, response, response_headers = make_request(m.interface.real_url(@rpath,@base),riddl_method,tp,th,tq,simulate,true)
321
323
  end
322
324
  return response if simulate
323
- if status < 200 || status >= 300 || !@wrapper.check_message(response,response_headers,m.out)
325
+ if status < 200 || status >= 300 || (!(last && ignore) && !@wrapper.check_message(response,response_headers,m.out))
324
326
  raise OutputError, "Not a valid output from service."
325
327
  end
326
328
  unless m == riddl_message.route.last
@@ -342,7 +344,7 @@ unless Module.constants.include?('CLIENT_INCLUDED')
342
344
  end #}}}
343
345
  private :exec_request
344
346
 
345
- def make_request(url,riddl_method,parameters,headers,qparams,simulate,ack) #{{{
347
+ def make_request(url,riddl_method,parameters,headers,qparams,simulate,ack,ignore=false) #{{{
346
348
  url = URI.parse(url)
347
349
  qs = qparams.join('&')
348
350
  if url.class == URI::HTTP || url.class == URI::HTTPS
@@ -371,8 +373,21 @@ unless Module.constants.include?('CLIENT_INCLUDED')
371
373
  opts[:verbose] = true ### sadly only to console, does not respect @options[:debug]
372
374
  end
373
375
 
376
+ # stream the body into the tempfile while receiving, so that large responses
377
+ # are not held in memory (without on_body, ethon collects the whole body)
378
+ bs = nil
379
+ unless ignore
380
+ bs = Parameter::Tempfile.new("RiddlBody")
381
+ bs.binmode
382
+ end
374
383
  begin
375
384
  req = Typhoeus::Request.new(uri,opts)
385
+ if ignore
386
+ req.on_body { |chunk,_| nil } # discard
387
+ else
388
+ bs.rewind; bs.truncate(0) # a redirect body must not end up in the result
389
+ req.on_body { |chunk,_| bs.write chunk; nil } # anything but :abort continues
390
+ end
376
391
  res = req.run
377
392
 
378
393
  response_headers = {}
@@ -389,8 +404,8 @@ unless Module.constants.include?('CLIENT_INCLUDED')
389
404
  end
390
405
  end while res.code.to_i == 302 || res.code.to_i == 301
391
406
 
392
- bs = Parameter::Tempfile.new("RiddlBody")
393
- bs.write res.body
407
+ return res.code.to_i, Riddl::Parameter::Array.new, response_headers if ignore
408
+
394
409
  bs.rewind
395
410
 
396
411
  response = Riddl::Protocols::HTTP::Parser.new(
@@ -52,9 +52,14 @@ module Riddl
52
52
  end
53
53
  class Tempfile < ::Tempfile
54
54
  def _close
55
- @tmpfile.close if @tmpfile
56
- @data[1] = nil if @data
57
- @tmpfile = nil
55
+ if @tmpfile # older rubies keep the file in @tmpfile (and @data for the finalizer)
56
+ @tmpfile.close
57
+ @data[1] = nil if @data
58
+ @tmpfile = nil
59
+ else # newer rubies (e.g. 3.4) only have the delegated file, @tmpfile is never set
60
+ f = __getobj__
61
+ f.close unless f.closed?
62
+ end
58
63
  end
59
64
  end
60
65
  end
data/riddl.gemspec CHANGED
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "1.0.20"
3
+ s.version = "1.0.21"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "Restful Interface Description and Declaration Language: tools and client/server libs"
7
7
 
8
8
  s.description = "REST service interface definition, mixing, and evolution. Supports mixed http and xmpp servers."
9
9
 
10
- s.files = Dir['{lib/ruby/riddl/ns/**/*,tools/**/*,ns/**/*,contrib/**/*,lib/ruby/riddl/**/*,examples/**/*}'] + %w(COPYING Rakefile riddl.gemspec README.md TODO AUTHORS INSTALL.md)
10
+ s.files = Dir['{lib/ruby/riddl/ns/**/*,tools/**/*,ns/**/*,contrib/**/*,lib/ruby/riddl/**/*,examples/**/*}'] + %w(LICENSE Rakefile riddl.gemspec README.md TODO AUTHORS INSTALL.md)
11
11
 
12
12
  s.require_path = 'lib/ruby'
13
13
  s.extra_rdoc_files = ['README.md']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.20
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen 'eTM' Mangler
@@ -253,8 +253,8 @@ extra_rdoc_files:
253
253
  - README.md
254
254
  files:
255
255
  - AUTHORS
256
- - COPYING
257
256
  - INSTALL.md
257
+ - LICENSE
258
258
  - README.md
259
259
  - Rakefile
260
260
  - TODO
@@ -533,7 +533,7 @@ homepage: http://github.com/etm/riddl/
533
533
  licenses:
534
534
  - LGPL-3.0-or-later
535
535
  metadata:
536
- documentation_uri: https://gemdocs.org/gems/riddl/1.0.20/
536
+ documentation_uri: https://gemdocs.org/gems/riddl/1.0.21/
537
537
  rdoc_options: []
538
538
  require_paths:
539
539
  - lib/ruby
File without changes