rest-man 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{multi-matrix-test.yml → ci.yml} +10 -1
- data/.github/workflows/single-matrix-test.yml +1 -0
- data/.gitignore +2 -0
- data/.rubocop-disables.yml +4 -29
- data/AUTHORS +5 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +3 -0
- data/README.md +30 -37
- data/Rakefile +1 -59
- data/_doc/lib/restman/abstract_response/_follow_redirection.rdoc +7 -0
- data/_doc/lib/restman/abstract_response/beautify_headers.rdoc +24 -0
- data/_doc/lib/restman/abstract_response/cookie_jar.rdoc +4 -0
- data/_doc/lib/restman/abstract_response/cookies.rdoc +12 -0
- data/_doc/lib/restman/abstract_response/follow_get_redirection.rdoc +2 -0
- data/_doc/lib/restman/abstract_response/follow_redirection.rdoc +2 -0
- data/_doc/lib/restman/abstract_response/headers.rdoc +2 -0
- data/_doc/lib/restman/abstract_response/response_set_vars.rdoc +5 -0
- data/_doc/lib/restman/abstract_response/return.rdoc +9 -0
- data/_doc/lib/restman/add_before_execution_proc.rdoc +2 -0
- data/_doc/lib/restman/create_log.rdoc +2 -0
- data/_doc/lib/restman/exception.rdoc +6 -0
- data/_doc/lib/restman/exceptions/timeout.rdoc +4 -0
- data/_doc/lib/restman/exceptions.rdoc +4 -0
- data/_doc/lib/restman/log=.rdoc +3 -0
- data/_doc/lib/restman/params_array/new.rdoc +20 -0
- data/_doc/lib/restman/params_array/process_pair.rdoc +4 -0
- data/_doc/lib/restman/params_array.rdoc +11 -0
- data/_doc/lib/restman/platform/jruby?.rdoc +4 -0
- data/_doc/lib/restman/platform/mac_mri?.rdoc +5 -0
- data/_doc/lib/restman/proxy.rdoc +2 -0
- data/_doc/lib/restman/proxy_set?.rdoc +5 -0
- data/_doc/lib/restman/raw_response/new.rdoc +6 -0
- data/_doc/lib/restman/raw_response.rdoc +10 -0
- data/_doc/lib/restman/request/cookie_jar.rdoc +3 -0
- data/_doc/lib/restman/request/cookies.rdoc +11 -0
- data/_doc/lib/restman/request/default_headers.rdoc +5 -0
- data/_doc/lib/restman/request/default_ssl_cert_store.rdoc +8 -0
- data/_doc/lib/restman/request/init/cookie_jar.rdoc +55 -0
- data/_doc/lib/restman/request/init/http_method.rdoc +15 -0
- data/_doc/lib/restman/request/make_cookie_header.rdoc +8 -0
- data/_doc/lib/restman/request/make_headers.rdoc +25 -0
- data/_doc/lib/restman/request/maybe_convert_extension.rdoc +18 -0
- data/_doc/lib/restman/request/process_result.rdoc +4 -0
- data/_doc/lib/restman/request/proxy_uri.rdoc +7 -0
- data/_doc/lib/restman/request/stringify_headers.rdoc +9 -0
- data/_doc/lib/restman/request/use_ssl.rdoc +4 -0
- data/_doc/lib/restman/request.rdoc +46 -0
- data/_doc/lib/restman/reset_before_execution_procs.rdoc +1 -0
- data/_doc/lib/restman/resource/[].rdoc +25 -0
- data/_doc/lib/restman/resource.rdoc +33 -0
- data/_doc/lib/restman/response/body.rdoc +7 -0
- data/_doc/lib/restman/response/create.rdoc +10 -0
- data/_doc/lib/restman/response/fix_encoding.rdoc +2 -0
- data/_doc/lib/restman/statuses.rdoc +11 -0
- data/_doc/lib/restman/utils/cgi_parse_header.rdoc +6 -0
- data/_doc/lib/restman/utils/encode_query_string.rdoc +90 -0
- data/_doc/lib/restman/utils/escape.rdoc +11 -0
- data/_doc/lib/restman/utils/flatten_params.rdoc +16 -0
- data/_doc/lib/restman/utils/get_encoding_from_headers.rdoc +24 -0
- data/_doc/lib/restman.rdoc +43 -0
- data/bin/console +15 -0
- data/lib/restman/abstract_response.rb +13 -60
- data/lib/restman/exception.rb +43 -0
- data/lib/restman/exceptions/exception_with_response.rb +7 -0
- data/lib/restman/exceptions/exceptions_map.rb +26 -0
- data/lib/restman/exceptions/request_failed.rb +15 -0
- data/lib/restman/exceptions/server_broke_connection.rb +13 -0
- data/lib/restman/exceptions/timeout.rb +37 -0
- data/lib/restman/params_array/process_pair.rb +39 -0
- data/lib/restman/params_array.rb +3 -48
- data/lib/restman/payload/base.rb +57 -0
- data/lib/restman/payload/multipart/write_content_disposition.rb +88 -0
- data/lib/restman/payload/multipart.rb +56 -0
- data/lib/restman/payload/streamed.rb +22 -0
- data/lib/restman/payload/url_encoded.rb +14 -0
- data/lib/restman/payload.rb +14 -196
- data/lib/restman/platform.rb +2 -18
- data/lib/restman/raw_response.rb +2 -14
- data/lib/restman/request/default_ssl_cert_store.rb +13 -0
- data/lib/restman/request/fetch_body_to_tempfile.rb +58 -0
- data/lib/restman/request/init/cookie_jar.rb +65 -0
- data/lib/restman/request/init/ssl_opts.rb +70 -0
- data/lib/restman/request/init/url/add_query_from_headers.rb +51 -0
- data/lib/restman/request/init/url/normalize_url.rb +19 -0
- data/lib/restman/request/init/url.rb +40 -0
- data/lib/restman/request/init.rb +106 -0
- data/lib/restman/request/log_request.rb +46 -0
- data/lib/restman/request/make_cookie_header.rb +16 -0
- data/lib/restman/request/make_headers.rb +39 -0
- data/lib/restman/request/maybe_convert_extension.rb +28 -0
- data/lib/restman/request/net_http_object.rb +25 -0
- data/lib/restman/request/process_result.rb +36 -0
- data/lib/restman/request/proxy_uri.rb +31 -0
- data/lib/restman/request/stringify_headers.rb +36 -0
- data/lib/restman/request/transmit.rb +152 -0
- data/lib/restman/request.rb +60 -745
- data/lib/restman/resource.rb +2 -60
- data/lib/restman/response.rb +3 -21
- data/lib/restman/statuses.rb +75 -0
- data/lib/restman/statuses_compatibility.rb +18 -0
- data/lib/restman/utils.rb +10 -206
- data/lib/restman/version.rb +1 -1
- data/lib/restman.rb +24 -62
- data/matrixeval.yml +19 -1
- data/rest-man.gemspec +4 -10
- data/spec/integration/capath_digicert/ce5e74ef.0 +1 -1
- data/spec/integration/request_spec.rb +13 -1
- data/spec/spec_helper.rb +11 -0
- data/spec/unit/abstract_response_spec.rb +14 -0
- data/spec/unit/exception_spec.rb +64 -0
- data/spec/unit/exceptions/backwards_campatibility_spec.rb +29 -0
- data/spec/unit/exceptions/exceptions_map_spec.rb +89 -0
- data/spec/unit/exceptions/request_failed_spec.rb +51 -0
- data/spec/unit/exceptions/server_broke_connection_spec.rb +8 -0
- data/spec/unit/exceptions/timeout_spec.rb +59 -0
- data/spec/unit/params_array/process_pair_spec.rb +59 -0
- data/spec/unit/params_array_spec.rb +15 -10
- data/spec/unit/payload/multipart_spec.rb +116 -0
- data/spec/unit/payload/streamed_spec.rb +48 -0
- data/spec/unit/payload/url_encoded_spec.rb +65 -0
- data/spec/unit/payload_spec.rb +0 -208
- data/spec/unit/request/init/url/add_query_from_headers_spec.rb +40 -0
- data/spec/unit/request/init/url/normalize_url_spec.rb +25 -0
- data/spec/unit/request/init_spec.rb +83 -0
- data/spec/unit/request_spec.rb +143 -151
- data/spec/unit/utils_spec.rb +96 -104
- metadata +132 -16
- data/lib/restman/exceptions.rb +0 -238
- data/lib/restman/windows/root_certs.rb +0 -105
- data/lib/restman/windows.rb +0 -8
- data/spec/unit/exceptions_spec.rb +0 -108
- data/spec/unit/windows/root_certs_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2a2ed4e6c9eb8299cb2b261f08ee19f8a8a6cb9716e3a92dd35f976f406f6a6
|
4
|
+
data.tar.gz: 959ea55211158eb81adde856be6144a62b5f9bd6e9bf0b3d294cb8ee41ab9cd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d92a3aa41d3447a1559466579314515950bb424a1a598310999841e77732d2ae604bb4b7ab5e868045aed1ea19d48fee0ba6ff4027828d9a221184a59a3bc73
|
7
|
+
data.tar.gz: 824b1be24cc6b19544d529a13f0aa18201cde6a9112ad331e6a1b35e56bc925e8ae7c2ca328b8b5c513dd5995716dc9079874e7ee4f4736f28afc6b02dad64fe
|
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: CI
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
@@ -18,6 +18,7 @@ jobs:
|
|
18
18
|
strategy:
|
19
19
|
matrix:
|
20
20
|
ruby:
|
21
|
+
- 2.6
|
21
22
|
- 2.7
|
22
23
|
- 3.0
|
23
24
|
- 3.1
|
@@ -32,4 +33,12 @@ jobs:
|
|
32
33
|
ruby-version: ${{ matrix.ruby }}
|
33
34
|
bundler-cache: true
|
34
35
|
- name: Run all tests with RSpec
|
36
|
+
env:
|
37
|
+
UPLOAD_COVERAGE_TO_CODACY: true
|
35
38
|
run: bundle exec rspec
|
39
|
+
- name: Run codacy-coverage-reporter
|
40
|
+
if: matrix.ruby == '3.1'
|
41
|
+
uses: codacy/codacy-coverage-reporter-action@v1
|
42
|
+
with:
|
43
|
+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
44
|
+
coverage-reports: coverage/coverage.xml
|
data/.gitignore
CHANGED
data/.rubocop-disables.yml
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# TODO
|
9
9
|
# Offense count: 1
|
10
10
|
# Cop supports --auto-correct.
|
11
|
-
Lint/
|
11
|
+
Lint/RedundantStringCoercion:
|
12
12
|
Enabled: false
|
13
13
|
|
14
14
|
# Tests only
|
@@ -17,18 +17,10 @@ Lint/StringConversionInInterpolation:
|
|
17
17
|
Lint/UnusedBlockArgument:
|
18
18
|
Enabled: false
|
19
19
|
|
20
|
-
|
21
|
-
Exclude:
|
22
|
-
- rest-man.windows.gemspec
|
23
|
-
|
24
|
-
Lint/HandleExceptions:
|
20
|
+
Lint/SuppressedException:
|
25
21
|
Exclude:
|
26
22
|
- lib/restman/utils.rb
|
27
23
|
|
28
|
-
Lint/UselessAccessModifier:
|
29
|
-
Exclude:
|
30
|
-
- lib/restman/windows/root_certs.rb
|
31
|
-
|
32
24
|
# Offense count: 4
|
33
25
|
# Cop supports --auto-correct.
|
34
26
|
Style/Alias:
|
@@ -46,17 +38,6 @@ Style/AndOr:
|
|
46
38
|
Style/BlockDelimiters:
|
47
39
|
Enabled: false
|
48
40
|
|
49
|
-
# Offense count: 48
|
50
|
-
# Cop supports --auto-correct.
|
51
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
52
|
-
Style/BracesAroundHashParameters:
|
53
|
-
Enabled: false
|
54
|
-
|
55
|
-
# Offense count: 1
|
56
|
-
Naming/ClassAndModuleCamelCase:
|
57
|
-
Exclude:
|
58
|
-
- lib/restman/windows/root_certs.rb
|
59
|
-
|
60
41
|
# Offense count: 2
|
61
42
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
62
43
|
Style/ClassAndModuleChildren:
|
@@ -184,7 +165,7 @@ Style/HashSyntax:
|
|
184
165
|
Style/IfUnlessModifier:
|
185
166
|
Enabled: false
|
186
167
|
|
187
|
-
Layout/
|
168
|
+
Layout/FirstHashElementIndentation:
|
188
169
|
Exclude:
|
189
170
|
- 'spec/**/*.rb'
|
190
171
|
|
@@ -364,7 +345,7 @@ Style/UnlessElse:
|
|
364
345
|
# TODO?
|
365
346
|
# Offense count: 6
|
366
347
|
# Cop supports --auto-correct.
|
367
|
-
Style/
|
348
|
+
Style/RedundantPercentQ:
|
368
349
|
Enabled: false
|
369
350
|
|
370
351
|
# Offense count: 5
|
@@ -378,9 +359,3 @@ Style/WordArray:
|
|
378
359
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
379
360
|
Style/BarePercentLiterals:
|
380
361
|
Enabled: false
|
381
|
-
|
382
|
-
|
383
|
-
Style/RescueStandardError:
|
384
|
-
Exclude:
|
385
|
-
- 'exe/restman'
|
386
|
-
- 'lib/restman/windows/root_certs.rb'
|
data/AUTHORS
CHANGED
@@ -20,7 +20,6 @@ Coda Hale
|
|
20
20
|
Crawford
|
21
21
|
Cyril Rohr
|
22
22
|
Dan Mayer
|
23
|
-
Dario Hamidi
|
24
23
|
Darren Coxall
|
25
24
|
David Backeus
|
26
25
|
David Perkowski
|
@@ -37,6 +36,7 @@ Giovanni Cappellotto
|
|
37
36
|
Greg Borenstein
|
38
37
|
Harm Aarts
|
39
38
|
Hiro Asari
|
39
|
+
Hopper Gee
|
40
40
|
Hugh McGowan
|
41
41
|
Ian Warshak
|
42
42
|
Igor Zubkov
|
@@ -77,12 +77,14 @@ Michael Klett
|
|
77
77
|
Michael Rykov
|
78
78
|
Michael Westbom
|
79
79
|
Mike Fletcher
|
80
|
+
Nathan Perry
|
80
81
|
Nelson Elhage
|
81
82
|
Nicholas Wieland
|
82
83
|
Nick Hammond
|
83
84
|
Nick Plante
|
84
85
|
Niko Dittmann
|
85
86
|
Nikolay Shebanov
|
87
|
+
Olle Jonsson
|
86
88
|
Oscar Del Ben
|
87
89
|
Pablo Astigarraga
|
88
90
|
Paul Dlug
|
@@ -95,11 +97,13 @@ Richard Schneeman
|
|
95
97
|
Rick Olson
|
96
98
|
Robert Eanes
|
97
99
|
Rodrigo Panachi
|
100
|
+
Ryan Guest
|
98
101
|
Sam Norbury
|
99
102
|
Samuel Cochran
|
100
103
|
Syl Turner
|
101
104
|
T. Watanabe
|
102
105
|
Tekin
|
106
|
+
The Gitter Badger
|
103
107
|
W. Andrew Loe III
|
104
108
|
Waynn Lue
|
105
109
|
Xavier Shay
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# v1.1.0
|
2
|
+
|
3
|
+
- Drop support for Ruby < 2.6
|
4
|
+
- Support Ruby 3.1, 3.2, JRuby-9.4
|
5
|
+
- Remove support for windows platform
|
6
|
+
- Support `write_timeout`, `ssl_timeout`, `keep_alive_timeout` option
|
7
|
+
- Support `max_retries` option
|
8
|
+
- Support `ssl_min_version` and `ssl_max_version` option
|
9
|
+
- Support `close_on_empty_response` option
|
10
|
+
- Support `local_host`, `local_port` option
|
11
|
+
- Add `AbstractRequest#sucess?`
|
12
|
+
- Move doc to seperate files
|
13
|
+
- Refactor most code with `ActiveMethod`
|
14
|
+
|
1
15
|
# 1.0.0
|
2
16
|
|
3
17
|
- Fork from rest-client and rename to rest-man
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# REST Man -- simple DSL for accessing HTTP and REST resources
|
2
2
|
|
3
|
+
[![CI](https://github.com/rest-man/rest-man/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/rest-man/rest-man/actions/workflows/ci.yml)
|
4
|
+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f68e8752d2c740129b82394f973de025)](https://www.codacy.com/gh/rest-man/rest-man/dashboard?utm_source=github.com&utm_medium=referral&utm_content=rest-man/rest-man&utm_campaign=Badge_Grade)
|
5
|
+
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/f68e8752d2c740129b82394f973de025)](https://www.codacy.com/gh/rest-man/rest-man/dashboard?utm_source=github.com&utm_medium=referral&utm_content=rest-man/rest-man&utm_campaign=Badge_Coverage)
|
6
|
+
|
3
7
|
A simple HTTP and REST client for Ruby, inspired by the Sinatra's microframework style
|
4
8
|
of specifying actions: get, put, post, delete.
|
5
9
|
|
@@ -7,23 +11,17 @@ This is a fork version of [rest-client](https://github.com/rest-client/rest-clie
|
|
7
11
|
|
8
12
|
## Requirements
|
9
13
|
|
10
|
-
|
11
|
-
2.0+ should work as well.
|
12
|
-
|
13
|
-
Earlier Ruby versions such as 1.8.7, 1.9.2, and 1.9.3 are no longer supported. These
|
14
|
-
versions no longer have any official support, and do not receive security
|
15
|
-
updates.
|
14
|
+
Supported Ruby versions
|
16
15
|
|
17
|
-
|
16
|
+
| 2.6 | 2.7 | 3.0 | 3.1 | 3.2 | 3.3-Preview |
|
17
|
+
| ---- | ---- | ---- | ---- | ---- | ---- |
|
18
|
+
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
18
19
|
|
19
|
-
|
20
|
-
* [netrc](http://rubygems.org/gems/netrc)
|
21
|
-
* [http-accept](https://rubygems.org/gems/http-accept)
|
22
|
-
* [http-cookie](https://rubygems.org/gems/http-cookie)
|
20
|
+
Supported JRuby versions
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
| 9.3 | 9.4 |
|
23
|
+
| ---- | ---- |
|
24
|
+
| ✅ | ✅ |
|
27
25
|
|
28
26
|
## Usage: Raw URL
|
29
27
|
|
@@ -202,7 +200,7 @@ Other `OpenSSL::SSL::SSLError` errors are raised as is.
|
|
202
200
|
|
203
201
|
By default, rest-man will follow HTTP 30x redirection requests.
|
204
202
|
|
205
|
-
|
203
|
+
`RestMan::Response` exposes a `#history` method that returns
|
206
204
|
a list of each response received in a redirection chain.
|
207
205
|
|
208
206
|
```ruby
|
@@ -224,12 +222,6 @@ a list of each response received in a redirection chain.
|
|
224
222
|
|
225
223
|
To disable automatic redirection, set `:max_redirects => 0`.
|
226
224
|
|
227
|
-
__New in 2.0:__ Prior versions of rest-man would raise
|
228
|
-
`RestMan::MaxRedirectsReached`, with no easy way to access the server's
|
229
|
-
response. In 2.0, rest-man raises the normal
|
230
|
-
`RestMan::ExceptionWithResponse` as it would with any other non-HTTP-20x
|
231
|
-
response.
|
232
|
-
|
233
225
|
```ruby
|
234
226
|
>> RestMan::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1')
|
235
227
|
=> RestMan::Response 200 "{\n "args":..."
|
@@ -258,6 +250,14 @@ RestMan::Found: 302 Found
|
|
258
250
|
=> RestMan::Response 200 "{\n "args":..."
|
259
251
|
```
|
260
252
|
|
253
|
+
#### Manually set max retries
|
254
|
+
|
255
|
+
The default max_retries is 1. You can change it to any number you like.
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
RestMan::Request.execute(method: :get, url: 'http://httpbin.org', max_retires: 0)
|
259
|
+
```
|
260
|
+
|
261
261
|
## Result handling
|
262
262
|
|
263
263
|
The result of a `RestMan::Request` is a `RestMan::Response` object.
|
@@ -271,9 +271,9 @@ Response objects have several useful methods. (See the class rdoc for more detai
|
|
271
271
|
- `Response#headers`: A hash of HTTP response headers
|
272
272
|
- `Response#raw_headers`: A hash of HTTP response headers as unprocessed arrays
|
273
273
|
- `Response#cookies`: A hash of HTTP cookies set by the server
|
274
|
-
- `Response#cookie_jar`:
|
274
|
+
- `Response#cookie_jar`: An HTTP::CookieJar of cookies
|
275
275
|
- `Response#request`: The RestMan::Request object used to make the request
|
276
|
-
- `Response#history`:
|
276
|
+
- `Response#history`: If redirection was followed, a list of prior Response objects
|
277
277
|
|
278
278
|
```ruby
|
279
279
|
RestMan.get('http://example.com')
|
@@ -602,7 +602,7 @@ use whatever proxy the system is configured to use:
|
|
602
602
|
RestMan.proxy = ENV['http_proxy']
|
603
603
|
```
|
604
604
|
|
605
|
-
|
605
|
+
Specify a per-request proxy by passing the :proxy option to
|
606
606
|
RestMan::Request. This will override any proxies set by environment variable
|
607
607
|
or by the global `RestMan.proxy` value.
|
608
608
|
|
@@ -702,7 +702,7 @@ GET:
|
|
702
702
|
{"outer"=>{"foo"=>"123", "bar"=>"456"}}
|
703
703
|
```
|
704
704
|
|
705
|
-
|
705
|
+
The `RestMan::ParamsArray` class allows callers to
|
706
706
|
provide ordering even to structured parameters. This is useful for unusual
|
707
707
|
cases where the server treats the order of parameters as significant or you
|
708
708
|
want to pass a particular key multiple times.
|
@@ -741,18 +741,18 @@ RestMan.delete 'http://example.com/resource', {:Authorization => 'Bearer cT0febF
|
|
741
741
|
|
742
742
|
By default the timeout for a request is 60 seconds. Timeouts for your request can
|
743
743
|
be adjusted by setting the `timeout:` to the number of seconds that you would like
|
744
|
-
the request to wait. Setting `timeout:` will override
|
744
|
+
the request to wait. Setting `timeout:` will override `read_timeout:`, `open_timeout:` and `write_timeout`.
|
745
745
|
|
746
746
|
```ruby
|
747
747
|
RestMan::Request.execute(method: :get, url: 'http://example.com/resource',
|
748
748
|
timeout: 120)
|
749
749
|
```
|
750
750
|
|
751
|
-
Additionally, you can set `read_timeout:` and `
|
751
|
+
Additionally, you can set `read_timeout:`, `open_timeout:` and `write_timeout` separately.
|
752
752
|
|
753
753
|
```ruby
|
754
754
|
RestMan::Request.execute(method: :get, url: 'http://example.com/resource',
|
755
|
-
read_timeout: 120, open_timeout: 240)
|
755
|
+
read_timeout: 120, open_timeout: 240, write_timeout: 120)
|
756
756
|
```
|
757
757
|
|
758
758
|
## Cookies
|
@@ -772,13 +772,9 @@ response2 = RestMan.post(
|
|
772
772
|
)
|
773
773
|
# ...response body
|
774
774
|
```
|
775
|
-
### Full cookie jar support
|
775
|
+
### Full cookie jar support
|
776
776
|
|
777
|
-
|
778
|
-
cookie RFC standards.
|
779
|
-
__New in 1.8__: An HTTP::CookieJar of cookies
|
780
|
-
|
781
|
-
Response objects now carry a cookie_jar method that exposes an HTTP::CookieJar
|
777
|
+
Response objects carry a cookie_jar method that exposes an HTTP::CookieJar
|
782
778
|
of cookies, which supports full standards compliant behavior.
|
783
779
|
|
784
780
|
## SSL/TLS support
|
@@ -838,6 +834,3 @@ Released under the MIT License: https://opensource.org/licenses/MIT
|
|
838
834
|
|
839
835
|
Photo of the International Space Station was produced by NASA and is in the
|
840
836
|
public domain.
|
841
|
-
|
842
|
-
Code for reading Windows root certificate store derived from work by Puppet;
|
843
|
-
used under terms of the Apache License, Version 2.0.
|
data/Rakefile
CHANGED
@@ -50,7 +50,7 @@ the following kind souls:
|
|
50
50
|
end
|
51
51
|
|
52
52
|
task :default do
|
53
|
-
sh 'rake
|
53
|
+
sh 'rake test'
|
54
54
|
end
|
55
55
|
|
56
56
|
def alias_task(alias_task, original)
|
@@ -61,64 +61,6 @@ alias_task(:test, :spec)
|
|
61
61
|
|
62
62
|
############################
|
63
63
|
|
64
|
-
WindowsPlatforms = %w{x86-mingw32 x64-mingw32 x86-mswin32}
|
65
|
-
|
66
|
-
namespace :all do
|
67
|
-
|
68
|
-
desc "Build rest-man #{RestMan::VERSION} for all platforms"
|
69
|
-
task :build => ['ruby:build'] + \
|
70
|
-
WindowsPlatforms.map {|p| "windows:#{p}:build"}
|
71
|
-
|
72
|
-
desc "Create tag v#{RestMan::VERSION} and for all platforms build and " \
|
73
|
-
"push rest-man #{RestMan::VERSION} to Rubygems"
|
74
|
-
task :release => ['build', 'ruby:release'] + \
|
75
|
-
WindowsPlatforms.map {|p| "windows:#{p}:push"}
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
namespace :windows do
|
80
|
-
spec_path = File.join(File.dirname(__FILE__), 'rest-man.windows.gemspec')
|
81
|
-
|
82
|
-
WindowsPlatforms.each do |platform|
|
83
|
-
namespace platform do
|
84
|
-
gem_filename = "rest-man-#{RestMan::VERSION}-#{platform}.gem"
|
85
|
-
base = File.dirname(__FILE__)
|
86
|
-
pkg_dir = File.join(base, 'pkg')
|
87
|
-
gem_file_path = File.join(pkg_dir, gem_filename)
|
88
|
-
|
89
|
-
desc "Build #{gem_filename} into the pkg directory"
|
90
|
-
task 'build' do
|
91
|
-
orig_platform = ENV['BUILD_PLATFORM']
|
92
|
-
begin
|
93
|
-
ENV['BUILD_PLATFORM'] = platform
|
94
|
-
|
95
|
-
sh("gem build -V #{spec_path}") do |ok, res|
|
96
|
-
if ok
|
97
|
-
FileUtils.mkdir_p(pkg_dir)
|
98
|
-
FileUtils.mv(File.join(base, gem_filename), pkg_dir)
|
99
|
-
Bundler.ui.confirm("rest-man #{RestMan::VERSION} " \
|
100
|
-
"built to pkg/#{gem_filename}")
|
101
|
-
else
|
102
|
-
abort "Command `gem build` failed: #{res}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
ensure
|
107
|
-
ENV['BUILD_PLATFORM'] = orig_platform
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
desc "Push #{gem_filename} to Rubygems"
|
112
|
-
task 'push' do
|
113
|
-
sh("gem push #{gem_file_path}")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
############################
|
121
|
-
|
122
64
|
require 'rdoc/task'
|
123
65
|
|
124
66
|
Rake::RDocTask.new do |t|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
:call-seq:
|
2
|
+
beautify_headers(headers) -> hash
|
3
|
+
|
4
|
+
Convert headers hash into canonical form.
|
5
|
+
|
6
|
+
Header names will be converted to lowercase symbols with underscores
|
7
|
+
instead of hyphens.
|
8
|
+
|
9
|
+
Headers specified multiple times will be joined by comma and space,
|
10
|
+
except for Set-Cookie, which will always be an array.
|
11
|
+
|
12
|
+
Per RFC 2616, if a server sends multiple headers with the same key, they
|
13
|
+
MUST be able to be joined into a single header by a comma. However,
|
14
|
+
Set-Cookie (RFC 6265) cannot because commas are valid within cookie
|
15
|
+
definitions. The newer RFC 7230 notes (3.2.2) that Set-Cookie should be
|
16
|
+
handled as a special case.
|
17
|
+
|
18
|
+
http://tools.ietf.org/html/rfc2616#section-4.2
|
19
|
+
http://tools.ietf.org/html/rfc7230#section-3.2.2
|
20
|
+
http://tools.ietf.org/html/rfc6265
|
21
|
+
|
22
|
+
[Parameters:]
|
23
|
+
|
24
|
+
- *headers* (Hash)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
:call-seq:
|
2
|
+
cookies -> hash
|
3
|
+
|
4
|
+
Hash of cookies extracted from response headers.
|
5
|
+
|
6
|
+
NB: This will return only cookies whose domain matches this request, and
|
7
|
+
may not even return all of those cookies if there are duplicate names.
|
8
|
+
Use the full cookie_jar for more nuanced access.
|
9
|
+
|
10
|
+
[See Also:]
|
11
|
+
|
12
|
+
- #cookie_jar
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Return the default behavior corresponding to the response code:
|
2
|
+
|
3
|
+
For 20x status codes: return the response itself
|
4
|
+
|
5
|
+
For 30x status codes:
|
6
|
+
301, 302, 307: redirect GET / HEAD if there is a Location header
|
7
|
+
303: redirect, changing method to GET, if there is a Location header
|
8
|
+
|
9
|
+
For all other responses, raise a response exception
|
@@ -0,0 +1,6 @@
|
|
1
|
+
This is the base RestMan exception class. Rescue it if you want to
|
2
|
+
catch any exception that your request might raise
|
3
|
+
You can get the status code by e.http_code, or see anything about the
|
4
|
+
response via e.response.
|
5
|
+
For example, the entire result body (which is
|
6
|
+
probably an HTML error page) is e.response.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
[Parameters:]
|
2
|
+
|
3
|
+
- array (Array) An array of parameter key,value pairs. These
|
4
|
+
pairs may be 2 element arrays [key, value] or single element hashes
|
5
|
+
{key => value}. They may also be single element arrays to represent a
|
6
|
+
key with no value.
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
*Examples*:
|
11
|
+
|
12
|
+
ParamsArray.new([[:foo, 123], [:foo, 456], [:bar, 789]])
|
13
|
+
|
14
|
+
This will be encoded as "foo=123&foo=456&bar=789"
|
15
|
+
|
16
|
+
ParamsArray.new({foo: 123, bar: 456})
|
17
|
+
|
18
|
+
This is valid, but there's no reason not to just use the Hash directly
|
19
|
+
instead of a ParamsArray.
|
20
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
The ParamsArray class is used to represent an ordered list of [key, value]
|
2
|
+
pairs. Use this when you need to include a key multiple times or want
|
3
|
+
explicit control over parameter ordering.
|
4
|
+
|
5
|
+
Most of the request payload & parameter functions normally accept a Hash of
|
6
|
+
keys => values, which does not allow for duplicated keys.
|
7
|
+
|
8
|
+
[See Also:]
|
9
|
+
|
10
|
+
- RestMan::Utils.encode_query_string
|
11
|
+
- RestMan::Utils.flatten_params
|
@@ -0,0 +1,10 @@
|
|
1
|
+
The response from RestMan on a raw request looks like a string, but is
|
2
|
+
actually one of these. 99% of the time you're making a rest call all you
|
3
|
+
care about is the body, but on the occasion you want to fetch the
|
4
|
+
headers you can:
|
5
|
+
|
6
|
+
RestMan.get('http://example.com').headers[:content_type]
|
7
|
+
|
8
|
+
In addition, if you do not use the response as a string, you can access
|
9
|
+
a Tempfile object at res.file, which contains the path to the raw
|
10
|
+
downloaded request body.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
:call-seq:
|
2
|
+
cookies -> hash
|
3
|
+
|
4
|
+
Render a hash of key => value pairs for cookies in the Request#cookie_jar
|
5
|
+
that are valid for the Request#uri. This will not necessarily include all
|
6
|
+
cookies if there are duplicate keys. It's safer to use the cookie_jar
|
7
|
+
directly if that's a concern.
|
8
|
+
|
9
|
+
[See Also:]
|
10
|
+
|
11
|
+
- Request#cookie_jar
|
@@ -0,0 +1,8 @@
|
|
1
|
+
:call-seq:
|
2
|
+
.default_ssl_cert_store -> OpenSSL::X509::Store
|
3
|
+
|
4
|
+
Return a certificate store that can be used to validate certificates with
|
5
|
+
the system certificate authorities. This will probably not do anything on
|
6
|
+
OS X, which monkey patches OpenSSL in terrible ways to insert its own
|
7
|
+
validation. On most *nix platforms, this will add the system certifcates
|
8
|
+
using OpenSSL::X509::Store#set_default_paths.
|