alovak-network 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,12 +49,10 @@ module Network
49
49
 
50
50
  def post(data)
51
51
  try_request do
52
- data = post_data(data)
53
-
54
52
  log_request(data, "POST")
55
53
  response = nil
56
54
  ms = Benchmark.realtime do
57
- response = http.post(uri.path, data, post_headers(data))
55
+ response = http.post(uri.request_uri, data, post_headers(data))
58
56
  end
59
57
  log_response(response, ms)
60
58
  response
@@ -63,13 +61,11 @@ module Network
63
61
 
64
62
  def get(data)
65
63
  try_request do
66
- data = post_data(data)
67
-
68
64
  log_request(data, "GET")
69
65
  response = nil
70
- query_string = uri.path + "?" + data
66
+ uri.query = (uri.select(:query) << data).join("&")
71
67
  ms = Benchmark.realtime do
72
- response = http.get(query_string)
68
+ response = http.get(uri.request_uri)
73
69
  end
74
70
  log_response(response, ms)
75
71
  response
@@ -115,10 +111,6 @@ module Network
115
111
  @headers
116
112
  end
117
113
 
118
- def post_data(data)
119
- uri.query ? [data, uri.query].join("&") : data
120
- end
121
-
122
114
  def configure_ssl(http)
123
115
  http.use_ssl = true
124
116
 
@@ -67,9 +67,9 @@ class TestConnectionWithParamsInURI < Test::Unit::TestCase
67
67
  sec = sequence('order')
68
68
 
69
69
  default_headers = { 'Content-Type' => 'application/x-www-form-urlencoded',
70
- 'Content-Length' => 'hello&route=some/where/else'.bytesize.to_s }
70
+ 'Content-Length' => 'hello'.bytesize.to_s }
71
71
 
72
- @http.expects(:post).with('/path', 'hello&route=some/where/else', default_headers)
72
+ @http.expects(:post).with('/path?route=some/where/else', 'hello', default_headers)
73
73
 
74
74
  @connection.expects(:log_request).in_sequence(sec)
75
75
  @connection.expects(:http).in_sequence(sec).returns(@http)
@@ -81,7 +81,7 @@ class TestConnectionWithParamsInURI < Test::Unit::TestCase
81
81
  def test_get_methods
82
82
  sec = sequence('order')
83
83
 
84
- @http.expects(:get).with('/path?query=hello&route=some/where/else')
84
+ @http.expects(:get).with('/path?route=some/where/else&query=hello')
85
85
 
86
86
  @connection.expects(:log_request).in_sequence(sec)
87
87
  @connection.expects(:http).in_sequence(sec).returns(@http)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alovak-network
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Gabriel