httparty 0.16.2 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.editorconfig +18 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +23 -0
- data/.gitignore +2 -0
- data/.rubocop_todo.yml +1 -1
- data/Changelog.md +425 -280
- data/Gemfile +7 -0
- data/Guardfile +3 -2
- data/README.md +5 -5
- data/docs/README.md +90 -5
- data/examples/README.md +28 -11
- data/examples/aaws.rb +6 -2
- data/examples/body_stream.rb +14 -0
- data/examples/idn.rb +10 -0
- data/examples/microsoft_graph.rb +52 -0
- data/examples/multipart.rb +22 -0
- data/examples/peer_cert.rb +9 -0
- data/examples/stream_download.rb +8 -2
- data/httparty.gemspec +4 -3
- data/lib/httparty/connection_adapter.rb +44 -20
- data/lib/httparty/cookie_hash.rb +10 -8
- data/lib/httparty/decompressor.rb +102 -0
- data/lib/httparty/exceptions.rb +3 -1
- data/lib/httparty/hash_conversions.rb +10 -4
- data/lib/httparty/headers_processor.rb +32 -0
- data/lib/httparty/logger/apache_formatter.rb +31 -6
- data/lib/httparty/logger/curl_formatter.rb +9 -7
- data/lib/httparty/logger/logger.rb +5 -1
- data/lib/httparty/logger/logstash_formatter.rb +62 -0
- data/lib/httparty/module_inheritable_attributes.rb +9 -9
- data/lib/httparty/net_digest_auth.rb +15 -15
- data/lib/httparty/parser.rb +12 -5
- data/lib/httparty/request/body.rb +54 -27
- data/lib/httparty/request/multipart_boundary.rb +2 -0
- data/lib/httparty/request.rb +105 -107
- data/lib/httparty/response/headers.rb +4 -2
- data/lib/httparty/response.rb +52 -9
- data/lib/httparty/response_fragment.rb +21 -0
- data/lib/httparty/text_encoder.rb +72 -0
- data/lib/httparty/utils.rb +13 -0
- data/lib/httparty/version.rb +3 -1
- data/lib/httparty.rb +81 -33
- data/script/release +4 -4
- data/website/css/common.css +1 -1
- metadata +50 -107
- data/.simplecov +0 -1
- data/.travis.yml +0 -10
- data/features/basic_authentication.feature +0 -20
- data/features/command_line.feature +0 -95
- data/features/deals_with_http_error_codes.feature +0 -26
- data/features/digest_authentication.feature +0 -30
- data/features/handles_compressed_responses.feature +0 -27
- data/features/handles_multiple_formats.feature +0 -57
- data/features/steps/env.rb +0 -27
- data/features/steps/httparty_response_steps.rb +0 -56
- data/features/steps/httparty_steps.rb +0 -43
- data/features/steps/mongrel_helper.rb +0 -127
- data/features/steps/remote_service_steps.rb +0 -92
- data/features/supports_read_timeout_option.feature +0 -13
- data/features/supports_redirection.feature +0 -22
- data/features/supports_timeout_option.feature +0 -13
- data/spec/fixtures/delicious.xml +0 -23
- data/spec/fixtures/empty.xml +0 -0
- data/spec/fixtures/google.html +0 -3
- data/spec/fixtures/ssl/generate.sh +0 -29
- data/spec/fixtures/ssl/generated/bogushost.crt +0 -13
- data/spec/fixtures/ssl/generated/ca.crt +0 -16
- data/spec/fixtures/ssl/generated/ca.key +0 -15
- data/spec/fixtures/ssl/generated/selfsigned.crt +0 -14
- data/spec/fixtures/ssl/generated/server.crt +0 -13
- data/spec/fixtures/ssl/generated/server.key +0 -15
- data/spec/fixtures/ssl/openssl-exts.cnf +0 -9
- data/spec/fixtures/tiny.gif +0 -0
- data/spec/fixtures/twitter.csv +0 -2
- data/spec/fixtures/twitter.json +0 -1
- data/spec/fixtures/twitter.xml +0 -403
- data/spec/fixtures/undefined_method_add_node_for_nil.xml +0 -2
- data/spec/httparty/connection_adapter_spec.rb +0 -498
- data/spec/httparty/cookie_hash_spec.rb +0 -100
- data/spec/httparty/exception_spec.rb +0 -45
- data/spec/httparty/hash_conversions_spec.rb +0 -56
- data/spec/httparty/logger/apache_formatter_spec.rb +0 -41
- data/spec/httparty/logger/curl_formatter_spec.rb +0 -119
- data/spec/httparty/logger/logger_spec.rb +0 -38
- data/spec/httparty/net_digest_auth_spec.rb +0 -270
- data/spec/httparty/parser_spec.rb +0 -190
- data/spec/httparty/request/body_spec.rb +0 -60
- data/spec/httparty/request_spec.rb +0 -1312
- data/spec/httparty/response_spec.rb +0 -347
- data/spec/httparty/ssl_spec.rb +0 -74
- data/spec/httparty_spec.rb +0 -896
- data/spec/spec_helper.rb +0 -51
- data/spec/support/ssl_test_helper.rb +0 -47
- data/spec/support/ssl_test_server.rb +0 -80
- data/spec/support/stub_response.rb +0 -49
@@ -1,60 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::Request::Body do
|
4
|
-
describe '#call' do
|
5
|
-
subject { described_class.new(params).call }
|
6
|
-
|
7
|
-
context 'when params is string' do
|
8
|
-
let(:params) { 'name=Bob%20Jones' }
|
9
|
-
|
10
|
-
it { is_expected.to eq params }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'when params is hash' do
|
14
|
-
let(:params) { { people: ["Bob Jones", "Mike Smith"] } }
|
15
|
-
let(:converted_params) { "people[]=Bob%20Jones&people[]=Mike%20Smith"}
|
16
|
-
|
17
|
-
it { is_expected.to eq converted_params }
|
18
|
-
|
19
|
-
context 'when params has file' do
|
20
|
-
before do
|
21
|
-
allow(HTTParty::Request::MultipartBoundary).
|
22
|
-
to receive(:generate).and_return("------------------------c772861a5109d5ef")
|
23
|
-
end
|
24
|
-
|
25
|
-
let(:params) do
|
26
|
-
{
|
27
|
-
user: {
|
28
|
-
avatar: File.open('spec/fixtures/tiny.gif'),
|
29
|
-
first_name: 'John',
|
30
|
-
last_name: 'Doe',
|
31
|
-
enabled: true
|
32
|
-
}
|
33
|
-
}
|
34
|
-
end
|
35
|
-
let(:multipart_params) do
|
36
|
-
"--------------------------c772861a5109d5ef\r\n" \
|
37
|
-
"Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"tiny.gif\"\r\n" \
|
38
|
-
"Content-Type: application/octet-stream\r\n" \
|
39
|
-
"\r\n" \
|
40
|
-
"GIF89a\u0001\u0000\u0001\u0000\u0000\xFF\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0000;\r\n" \
|
41
|
-
"--------------------------c772861a5109d5ef\r\n" \
|
42
|
-
"Content-Disposition: form-data; name=\"user[first_name]\"\r\n" \
|
43
|
-
"\r\n" \
|
44
|
-
"John\r\n" \
|
45
|
-
"--------------------------c772861a5109d5ef\r\n" \
|
46
|
-
"Content-Disposition: form-data; name=\"user[last_name]\"\r\n" \
|
47
|
-
"\r\n" \
|
48
|
-
"Doe\r\n" \
|
49
|
-
"--------------------------c772861a5109d5ef\r\n" \
|
50
|
-
"Content-Disposition: form-data; name=\"user[enabled]\"\r\n" \
|
51
|
-
"\r\n" \
|
52
|
-
"true\r\n" \
|
53
|
-
"--------------------------c772861a5109d5ef--\r\n"
|
54
|
-
end
|
55
|
-
|
56
|
-
it { is_expected.to eq multipart_params }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|