flexirest 1.7.7 → 1.7.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f360dc2f87aa9c1b0509dd70415e202088643e535159206f350eb9f1ef7814c
4
- data.tar.gz: 7c68d576f0719bfbe522b216d9e17ee7e72fa76aa03317e0937b5c69488bb845
3
+ metadata.gz: 392084cff2b3134307881a8e998b561ff49c8f5f3db22f5e6af4df495a8f8790
4
+ data.tar.gz: cd6928e4802e733483ea04de70765f2d069181b1f445ccb1ba188a3d247d8908
5
5
  SHA512:
6
- metadata.gz: c8c2e739b3be3d1088985704fb1e629d55f92117273ef47e631eebac7f1f28ea844bcdc703351aeb1189f907653d34534c3c8839258e5236593a2c501e4ae362
7
- data.tar.gz: edf8def024e7364381180d117e62c1b7f0c4adc9f34329bc16a4032c0e13df0a41554ed2b0bfe8e924ff3772237288be5992cc4f432eb9a8cf7393d51e36c67e
6
+ metadata.gz: 65c520be2d605b87e665599e9bcc0d5d59752c86aa5cf68d17273ec894832296b37058fa13c700a57214c3a8255edd306f789c679a203c2daad35c375bf9b55a
7
+ data.tar.gz: f2dfcf7aa20f178d9dff64232577dc4a3810f77877d089ef85222ae78aa4c17df7ddc213691f8d104c8f8ff91a6f9e63e63097217ac56bc8e3f63da8b1ab9c82
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.8
4
+
5
+ Fix:
6
+
7
+ - plain requests to URLs that are just the domain e.g. "https://www.example.com" should also work (i.e. without any trailing path, even a '/')
8
+
3
9
  ## 1.7.7
4
10
 
5
11
  Change:
@@ -18,6 +18,7 @@ For available configuration variables look into the [Faraday documentation](http
18
18
  Flexirest::Base.faraday_config do |faraday|
19
19
  faraday.adapter(:net_http)
20
20
  faraday.options.timeout = 10
21
+ faraday.ssl.verify = false
21
22
  faraday.headers['User-Agent'] = "Flexirest/#{Flexirest::VERSION}"
22
23
  end
23
24
  ```
@@ -459,7 +459,7 @@ module Flexirest
459
459
  connection = Flexirest::ConnectionManager.get_connection(base_url)
460
460
  end
461
461
  else
462
- parts = @url.match(%r{^(https?://[a-z\d\.:-]+?)(/.*)}).to_a
462
+ parts = @url.match(%r{^(https?://[a-z\d\.:-]+?)(/.*)?$}).to_a
463
463
  if (parts.empty?) # Not a full URL, so use hostname/protocol from existing base_url
464
464
  uri = URI.parse(base_url)
465
465
  @base_url = "#{uri.scheme}://#{uri.host}#{":#{uri.port}" if uri.port != 80 && uri.port != 443}"
@@ -1,3 +1,3 @@
1
1
  module Flexirest
2
- VERSION = "1.7.7"
2
+ VERSION = "1.7.8"
3
3
  end
@@ -330,14 +330,14 @@ describe Flexirest::BaseWithoutValidation do
330
330
 
331
331
  it "passes headers" do
332
332
  stub_request(:get, "http://api.example.com/v1").
333
- with(headers: {'Accept'=>'application/hal+json, application/json;q=0.5', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Connection'=>'Keep-Alive', 'Content-Type'=>'application/x-www-form-urlencoded', 'X-Something'=>'foo/bar', 'User-Agent'=>/Flexirest\//}).
333
+ with(headers: {'Accept'=>'application/hal+json, application/json;q=0.5', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Connection'=>'Keep-Alive', 'Content-Type'=>'application/x-www-form-urlencoded; charset=utf-8', 'X-Something'=>'foo/bar', 'User-Agent'=>/Flexirest\//}).
334
334
  to_return(status: 200, body: "", headers: {})
335
335
  EmptyExample._request("http://api.example.com/v1", :get, {}, {headers: {"X-Something" => "foo/bar"}})
336
336
  end
337
337
 
338
338
  it "passes headers if the response is unparsed" do
339
339
  stub_request(:get, "http://api.example.com/v1").
340
- with(headers: {'Accept'=>'application/hal+json, application/json;q=0.5', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Connection'=>'Keep-Alive', 'Content-Type'=>'application/x-www-form-urlencoded', 'X-Something'=>'foo/bar', 'User-Agent'=>/Flexirest\//}).
340
+ with(headers: {'Accept'=>'application/hal+json, application/json;q=0.5', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Connection'=>'Keep-Alive', 'Content-Type'=>'application/x-www-form-urlencoded; charset=utf-8', 'X-Something'=>'foo/bar', 'User-Agent'=>/Flexirest\//}).
341
341
  to_return(status: 200, body: "", headers: {})
342
342
  EmptyExample._plain_request("http://api.example.com/v1", :get, {}, {headers: {"X-Something" => "foo/bar"}})
343
343
  end
@@ -367,7 +367,13 @@ describe Flexirest::BaseWithoutValidation do
367
367
  it "should be able to pass the plain response from the directly called URL bypassing JSON loading" do
368
368
  response_body = "This is another non-JSON string"
369
369
  expect_any_instance_of(Flexirest::Connection).to receive(:post).with(any_args).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, response_headers:{}, body:response_body)))
370
- expect(EmptyExample._plain_request("http://api.example.com/", :post, {id:1234})).to eq(response_body)
370
+ expect(EmptyExample._plain_request("http://api.example.com/v1/something", :post, {id:1234})).to eq(response_body)
371
+ end
372
+
373
+ it "should be able to pass the plain response from the directly called URL bypassing JSON loading" do
374
+ response_body = "This is another non-JSON string"
375
+ expect_any_instance_of(Flexirest::Connection).to receive(:post).with(any_args).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, response_headers:{}, body:response_body)))
376
+ expect(EmptyExample._plain_request("http://api.example.com", :post, {id:1234})).to eq(response_body)
371
377
  end
372
378
 
373
379
  it "should return a PlainResponse from the directly called URL bypassing JSON loading" do
@@ -794,7 +794,7 @@ describe Flexirest::Request do
794
794
  rescue Flexirest::HTTPServerException => e
795
795
  e
796
796
  end
797
- expect(e.message).to eq(%q{Sending POST to '/create' returned a 500 with the body of - {"first_name":"John", "id":1234}})
797
+ expect(e.message).to eq(%q{The POST to '/create' returned a 500 status, which raised a Flexirest::HTTPServerException with a body of: \{"first_name":"John", "id":1234\}})
798
798
  end
799
799
 
800
800
  it "should raise a parse exception for invalid JSON returns" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexirest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.7
4
+ version: 1.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-03 00:00:00.000000000 Z
11
+ date: 2019-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler