riddl 0.99.259 → 0.99.260

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
  SHA1:
3
- metadata.gz: 6c1b1de9fbd47a1665ad047a232d807495494c98
4
- data.tar.gz: 81b689137e2261461a548368b16bac9bbb97cc27
3
+ metadata.gz: a3826c3cbdc75fe88d6d8d1635127c693a6f61e4
4
+ data.tar.gz: 8651dcd9448e6ca7d2bb0e49124271ec05785cbc
5
5
  SHA512:
6
- metadata.gz: ee00e0900b1d2a13fe3014060ee28fbf34296b2dacf3386fa2cf805b98af65543ec9107f2dbfc5e3659cbd98dc07636fc92df77f989b9282ac48382bbbc7880d
7
- data.tar.gz: '080f54624dd6fcb6cf80ef0a8a8de957185b40638f4c85a9d5cd0b4c931a21a01b9e55a709bc87c601be7e3029bfe00990f38d2420dc276af63f3d4ca22f918f'
6
+ metadata.gz: 0730b16245a088f76fdd2e28a3be7b23212e3ed542f22e036c2389d3bcb62b71e33f7202906eca78666089c0782840d7cd8224ff053e8c3a635469da4cbc160a
7
+ data.tar.gz: 79b3c5132e86b5f584e2766e98b4a8e67ba6b38bbe38ef4f0a64d474945b46f5a7f4edee28370b91457c6afb0eb638754da50468f14aca5075f74264c7a70ac5
File without changes
@@ -2,7 +2,7 @@
2
2
  require '../../lib/ruby/riddl/client'
3
3
  require 'pp'
4
4
 
5
- library = Riddl::Client.new("http://sumatra.wst.univie.ac.at/services/delay.php")
5
+ library = Riddl::Client.new("http://demo.wst.univie.ac.at/services/delay.php")
6
6
  status, res = library.post [
7
7
  Riddl::Parameter::Simple.new("delay","10"),
8
8
  ]
@@ -14,4 +14,4 @@ p id
14
14
  pp status
15
15
  pp res[0]
16
16
  sleep 1
17
- end
17
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/ruby
2
+ require '../../lib/ruby/riddl/client'
3
+ require 'pp'
4
+
5
+ uri = 'https://mangler:test@httpbin.org/digest-auth/auth/mangler/test/MD5/never'
6
+
7
+ library = Riddl::Client.new(uri)
8
+ status, res = library.get
9
+
10
+ p status
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby
2
+ require '../../lib/ruby/riddl/client'
3
+ #require 'riddl/client'
4
+ require 'pp'
5
+
6
+ uri = 'http://gruppe.wst.univie.ac.at/~mangler/services/oebb.php?_taetigkeiten=taetigkeiten.txt&strategie=IS1&_schaedigungen=schaedigungen.txt'
7
+
8
+ s = Time.now
9
+ library = Riddl::Client.new(uri)
10
+ status, res = library.post [
11
+ Riddl::Parameter::Simple.new("delay","10")
12
+ ]
13
+ p status
14
+ puts res[0].value.read
15
+ puts Time.now-s
16
+
File without changes
@@ -6,7 +6,7 @@ require File.expand_path(File.dirname(__FILE__) + '/protocols/utils')
6
6
  require File.expand_path(File.dirname(__FILE__) + '/header')
7
7
  require File.expand_path(File.dirname(__FILE__) + '/option')
8
8
 
9
- require 'net/https'
9
+ require 'typhoeus'
10
10
  require 'eventmachine'
11
11
  require 'em-websocket-client'
12
12
  require 'uri'
@@ -241,7 +241,7 @@ unless Module.constants.include?('CLIENT_INCLUDED')
241
241
  starting = true
242
242
  parameters.delete_if do |p|
243
243
  if starting && p.class == Riddl::Parameter::Simple && method == 'get'
244
- p.type = :query
244
+ p.type = :query
245
245
  end
246
246
  if p.class == Riddl::Parameter::Simple && p.type == :query
247
247
  qparams << Protocols::Utils::escape(p.name) + (p.value.nil? ? '' : '=' + Protocols::Utils::escape(p.value))
@@ -336,54 +336,55 @@ unless Module.constants.include?('CLIENT_INCLUDED')
336
336
  qs = qparams.join('&')
337
337
  if url.class == URI::HTTP || url.class == URI::HTTPS
338
338
  #{{{
339
- req = Riddl::Client::HTTPRequest.new(riddl_method,url.path,parameters,headers,qs)
340
- return req.simulate if simulate
341
-
342
- res = response = nil
343
-
344
- http = Net::HTTP.new(url.host, url.port)
345
- if url.class == URI::HTTPS
346
- http.use_ssl = true
347
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
339
+ return Riddl::Client::HTTPRequest.new(riddl_method,url.path,parameters,headers,qs).simulate if simulate
340
+
341
+ path = (url.path.strip == '' ? '/' : url.path)
342
+ path += "?#{qs}" unless qs == ''
343
+ uri = url.scheme + '://' + url.host + ':' + url.port.to_s + path
344
+
345
+ tmp = Protocols::HTTP::Generator.new(parameters,headers).generate(:input)
346
+
347
+ opts = {
348
+ :method => riddl_method,
349
+ :headers => headers,
350
+ :body => tmp.read,
351
+ :ssl_verifypeer => false
352
+ }
353
+ if url.user && url.password
354
+ opts[:username] = url.user
355
+ opts[:password] = url.password
356
+ opts[:httpauth] = :auto
348
357
  end
349
358
  if @options[:debug]
350
- http.set_debug_output @options[:debug]
351
- end
352
- http.start do
353
- retrycount = 0
354
- begin
355
- http.request(req) do |resp|
356
- res = resp
357
- bs = Parameter::Tempfile.new("RiddlBody")
358
- res.read_body(bs)
359
- bs.rewind
360
- response = Riddl::Protocols::HTTP::Parser.new(
361
- "",
362
- bs,
363
- res['CONTENT-TYPE'],
364
- res['CONTENT-LENGTH'].to_i != bs.length ? 0 : res['CONTENT-LENGTH'], # because when gzip content length differs from bs length
365
- res['CONTENT-DISPOSITION'],
366
- res['CONTENT-ID'],
367
- res['RIDDL-TYPE']
368
- ).params
369
- end
370
- rescue => e
371
- retrycount += 1
372
- if retrycount < 4
373
- retry
374
- else
375
- raise Riddl::ConnectionError, "#{url.host}:#{url.port}/#{url.path} not reachable - #{e.message}."
376
- end
377
- end
359
+ opts[:verbose] = true ### sadly only to console, does not respect @options[:debug]
378
360
  end
361
+
362
+ req = Typhoeus::Request.new(uri,opts)
363
+ res = req.run
364
+
365
+ bs = Parameter::Tempfile.new("RiddlBody")
366
+ bs.write res.body
367
+ bs.rewind
368
+
379
369
  response_headers = {}
380
- res.each do |k,v|
370
+ res.headers.each do |k,v|
381
371
  if v.nil?
382
372
  response_headers[k.name.upcase.gsub(/\-/,'_')] = v
383
373
  else
384
374
  response_headers[k.upcase.gsub(/\-/,'_')] = v
385
375
  end
386
376
  end
377
+
378
+ response = Riddl::Protocols::HTTP::Parser.new(
379
+ "",
380
+ bs,
381
+ response_headers['CONTENT_TYPE'],
382
+ response_headers['CONTENT_LENGTH'].to_i != bs.length ? 0 : response_headers['CONTENT_LENGTH'], # because when gzip content length differs from bs length
383
+ response_headers['CONTENT_DISPOSITION'],
384
+ response_headers['CONTENT_ID'],
385
+ response_headers['RIDDL_TYPE']
386
+ ).params
387
+
387
388
  return res.code.to_i, response, response_headers
388
389
  #}}}
389
390
  else
@@ -397,7 +398,7 @@ unless Module.constants.include?('CLIENT_INCLUDED')
397
398
 
398
399
  end #}}}
399
400
 
400
- class HTTPRequest < Net::HTTPGenericRequest #{{{
401
+ class HTTPRequest #{{{
401
402
  def initialize(method, path, parameters, headers, qs)
402
403
  path = (path.strip == '' ? '/' : path)
403
404
  path += "?#{qs}" unless qs == ''
@@ -407,10 +408,6 @@ unless Module.constants.include?('CLIENT_INCLUDED')
407
408
  self.body_stream = tmp
408
409
  end
409
410
 
410
- def supply_default_content_type
411
- ### none, Protocols::HTTP::Generator handles this
412
- end
413
-
414
411
  def simulate
415
412
  sock = StringIO.new('')
416
413
  sock.define_singleton_method(:io) do
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.99.259"
3
+ s.version = "0.99.260"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "restful interface description and declaration language: tools and client/server libs"
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.required_ruby_version = '>=2.2.0'
25
25
 
26
+ s.add_runtime_dependency 'typhoeus', '~>1.3'
26
27
  s.add_runtime_dependency 'xml-smart', '>=0.3.6', '~>0'
27
28
  s.add_runtime_dependency 'rdf-smart', '>=0.0.160', '~>0'
28
29
  s.add_runtime_dependency 'rack', '~>1.6'
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: 0.99.259
4
+ version: 0.99.260
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen 'eTM' Mangler
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: tools
12
12
  cert_chain: []
13
- date: 2018-01-18 00:00:00.000000000 Z
13
+ date: 2018-01-25 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: typhoeus
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.3'
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: xml-smart
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -239,7 +253,11 @@ files:
239
253
  - contrib/riddl.jpg
240
254
  - contrib/riddl.png
241
255
  - contrib/riddl.svg
242
- - examples/client/client.rb
256
+ - examples/client/password,
257
+ - examples/client/test1.rb
258
+ - examples/client/test2.rb
259
+ - examples/client/test3.rb
260
+ - examples/client/username,
243
261
  - examples/declaration-server-distributed/README
244
262
  - examples/declaration-server-distributed/declaration.rb
245
263
  - examples/declaration-server-distributed/declaration.xml