alovak-network 1.2.1 → 1.2.2
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.
- data/lib/network/connection.rb +3 -11
- data/test/network/test_connection.rb +3 -3
- metadata +1 -1
    
        data/lib/network/connection.rb
    CHANGED
    
    | @@ -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. | 
| 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 | 
            -
                     | 
| 66 | 
            +
                    uri.query = (uri.select(:query) << data).join("&")
         | 
| 71 67 | 
             
                    ms = Benchmark.realtime do 
         | 
| 72 | 
            -
                      response = http.get( | 
| 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 | 
| 70 | 
            +
                                    'Content-Length' => 'hello'.bytesize.to_s }
         | 
| 71 71 |  | 
| 72 | 
            -
                @http.expects(:post).with('/path | 
| 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? | 
| 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)
         |