httparty 0.16.2 → 0.16.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of httparty might be problematic. Click here for more details.

Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +18 -0
  3. data/.gitignore +1 -0
  4. data/Changelog.md +11 -0
  5. data/README.md +1 -1
  6. data/examples/README.md +22 -11
  7. data/examples/body_stream.rb +14 -0
  8. data/examples/microsoft_graph.rb +52 -0
  9. data/examples/multipart.rb +22 -0
  10. data/features/steps/mongrel_helper.rb +3 -3
  11. data/httparty.gemspec +2 -1
  12. data/lib/httparty.rb +21 -1
  13. data/lib/httparty/connection_adapter.rb +11 -4
  14. data/lib/httparty/hash_conversions.rb +6 -2
  15. data/lib/httparty/logger/apache_formatter.rb +29 -6
  16. data/lib/httparty/logger/curl_formatter.rb +4 -4
  17. data/lib/httparty/logger/logger.rb +3 -1
  18. data/lib/httparty/logger/logstash_formatter.rb +59 -0
  19. data/lib/httparty/module_inheritable_attributes.rb +3 -3
  20. data/lib/httparty/net_digest_auth.rb +6 -5
  21. data/lib/httparty/request.rb +8 -1
  22. data/lib/httparty/request/body.rb +16 -5
  23. data/lib/httparty/response.rb +19 -5
  24. data/lib/httparty/response/headers.rb +2 -2
  25. data/lib/httparty/utils.rb +11 -0
  26. data/lib/httparty/version.rb +1 -1
  27. data/spec/httparty/connection_adapter_spec.rb +7 -3
  28. data/spec/httparty/cookie_hash_spec.rb +1 -1
  29. data/spec/httparty/exception_spec.rb +1 -1
  30. data/spec/httparty/hash_conversions_spec.rb +2 -0
  31. data/spec/httparty/logger/apache_formatter_spec.rb +1 -2
  32. data/spec/httparty/logger/curl_formatter_spec.rb +1 -1
  33. data/spec/httparty/logger/logger_spec.rb +6 -1
  34. data/spec/httparty/logger/logstash_formatter_spec.rb +44 -0
  35. data/spec/httparty/net_digest_auth_spec.rb +22 -22
  36. data/spec/httparty/parser_spec.rb +1 -1
  37. data/spec/httparty/request/body_spec.rb +57 -8
  38. data/spec/httparty/request_spec.rb +68 -13
  39. data/spec/httparty/response_spec.rb +32 -20
  40. data/spec/httparty/ssl_spec.rb +1 -1
  41. data/spec/httparty_spec.rb +28 -7
  42. data/website/css/common.css +1 -1
  43. metadata +25 -3
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  RSpec.describe HTTParty::Request do
4
4
  context "SSL certificate verification" do
@@ -1,5 +1,3 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
-
3
1
  RSpec.describe HTTParty do
4
2
  before(:each) do
5
3
  @klass = Class.new
@@ -144,34 +142,44 @@ RSpec.describe HTTParty do
144
142
  expect(@klass.headers).to eq(init_headers)
145
143
  end
146
144
 
145
+ it "should be able to accept block as header value" do
146
+ init_headers = {'foo' => lambda {'bar'}}
147
+ @klass.headers init_headers
148
+
149
+ stub_request(:get, "http://example.com/").with(headers: {'foo' => 'bar', 'baz' => 'spax'})
150
+
151
+ @klass.get('http://example.com/', headers: {'baz' => -> {'spax'}})
152
+ expect(@klass.headers).to eq(init_headers)
153
+ end
154
+
147
155
  it "uses the class headers when sending a request" do
148
- expect_headers(foo: 'bar')
156
+ expect_headers('foo' => 'bar')
149
157
  @klass.headers(foo: 'bar')
150
158
  @klass.get('')
151
159
  end
152
160
 
153
161
  it "merges class headers with request headers" do
154
- expect_headers(baz: 'spax', foo: 'bar')
162
+ expect_headers('baz' => 'spax', 'foo' => 'bar')
155
163
  @klass.headers(foo: 'bar')
156
164
  @klass.get('', headers: {baz: 'spax'})
157
165
  end
158
166
 
159
167
  it 'overrides class headers with request headers' do
160
- expect_headers(baz: 'spax', foo: 'baz')
168
+ expect_headers('baz' => 'spax', 'foo' => 'baz')
161
169
  @klass.headers(foo: 'bar')
162
170
  @klass.get('', headers: {baz: 'spax', foo: 'baz'})
163
171
  end
164
172
 
165
173
  context "with cookies" do
166
174
  it 'utilizes the class-level cookies' do
167
- expect_headers(foo: 'bar', 'cookie' => 'type=snickerdoodle')
175
+ expect_headers('foo' => 'bar', 'cookie' => 'type=snickerdoodle')
168
176
  @klass.headers(foo: 'bar')
169
177
  @klass.cookies(type: 'snickerdoodle')
170
178
  @klass.get('')
171
179
  end
172
180
 
173
181
  it 'adds cookies to the headers' do
174
- expect_headers(foo: 'bar', 'cookie' => 'type=snickerdoodle')
182
+ expect_headers('foo' => 'bar', 'cookie' => 'type=snickerdoodle')
175
183
  @klass.headers(foo: 'bar')
176
184
  @klass.get('', cookies: {type: 'snickerdoodle'})
177
185
  end
@@ -205,6 +213,19 @@ RSpec.describe HTTParty do
205
213
  @klass.post('http://example.com', body: { file: File.open('spec/fixtures/tiny.gif')})
206
214
  end
207
215
  end
216
+
217
+ context 'when headers passed as symbols' do
218
+ let(:headers) { { 'foo' => 'application/json', 'bar' => 'example' } }
219
+
220
+ it 'converts them to string' do
221
+ expect(HTTParty::Request).to receive(:new)
222
+ .with(anything, anything, hash_including({ headers: headers }))
223
+ .and_return(double("mock response", perform: nil))
224
+
225
+ @klass.headers(foo: 'application/json')
226
+ @klass.post('http://example.com', headers: { bar: 'example' })
227
+ end
228
+ end
208
229
  end
209
230
 
210
231
  describe "cookies" do
@@ -8,7 +8,7 @@
8
8
  body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
9
9
  body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
10
10
  /* end of yahoo reset and fonts */
11
-
11
+
12
12
  body {color:#333; background:#4b1a1a; line-height:1.3;}
13
13
  p {margin:0 0 20px;}
14
14
  a {color:#4b1a1a;}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.2
4
+ version: 0.16.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-30 00:00:00.000000000 Z
12
+ date: 2018-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_xml
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.5.2
28
+ - !ruby/object:Gem::Dependency
29
+ name: mime-types
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.0'
28
42
  description: Makes http fun! Also, makes consuming restful web services dead easy.
29
43
  email:
30
44
  - nunemaker@gmail.com
@@ -33,6 +47,7 @@ executables:
33
47
  extensions: []
34
48
  extra_rdoc_files: []
35
49
  files:
50
+ - ".editorconfig"
36
51
  - ".gitignore"
37
52
  - ".rubocop.yml"
38
53
  - ".rubocop_todo.yml"
@@ -51,12 +66,15 @@ files:
51
66
  - examples/README.md
52
67
  - examples/aaws.rb
53
68
  - examples/basic.rb
69
+ - examples/body_stream.rb
54
70
  - examples/crack.rb
55
71
  - examples/custom_parsers.rb
56
72
  - examples/delicious.rb
57
73
  - examples/google.rb
58
74
  - examples/headers_and_user_agents.rb
59
75
  - examples/logging.rb
76
+ - examples/microsoft_graph.rb
77
+ - examples/multipart.rb
60
78
  - examples/nokogiri_html_parser.rb
61
79
  - examples/rescue_json.rb
62
80
  - examples/rubyurl.rb
@@ -88,6 +106,7 @@ files:
88
106
  - lib/httparty/logger/apache_formatter.rb
89
107
  - lib/httparty/logger/curl_formatter.rb
90
108
  - lib/httparty/logger/logger.rb
109
+ - lib/httparty/logger/logstash_formatter.rb
91
110
  - lib/httparty/module_inheritable_attributes.rb
92
111
  - lib/httparty/net_digest_auth.rb
93
112
  - lib/httparty/parser.rb
@@ -96,6 +115,7 @@ files:
96
115
  - lib/httparty/request/multipart_boundary.rb
97
116
  - lib/httparty/response.rb
98
117
  - lib/httparty/response/headers.rb
118
+ - lib/httparty/utils.rb
99
119
  - lib/httparty/version.rb
100
120
  - script/release
101
121
  - spec/fixtures/delicious.xml
@@ -121,6 +141,7 @@ files:
121
141
  - spec/httparty/logger/apache_formatter_spec.rb
122
142
  - spec/httparty/logger/curl_formatter_spec.rb
123
143
  - spec/httparty/logger/logger_spec.rb
144
+ - spec/httparty/logger/logstash_formatter_spec.rb
124
145
  - spec/httparty/net_digest_auth_spec.rb
125
146
  - spec/httparty/parser_spec.rb
126
147
  - spec/httparty/request/body_spec.rb
@@ -134,7 +155,7 @@ files:
134
155
  - spec/support/stub_response.rb
135
156
  - website/css/common.css
136
157
  - website/index.html
137
- homepage: http://jnunemaker.github.com/httparty
158
+ homepage: https://github.com/jnunemaker/httparty
138
159
  licenses:
139
160
  - MIT
140
161
  metadata: {}
@@ -196,6 +217,7 @@ test_files:
196
217
  - spec/httparty/logger/apache_formatter_spec.rb
197
218
  - spec/httparty/logger/curl_formatter_spec.rb
198
219
  - spec/httparty/logger/logger_spec.rb
220
+ - spec/httparty/logger/logstash_formatter_spec.rb
199
221
  - spec/httparty/net_digest_auth_spec.rb
200
222
  - spec/httparty/parser_spec.rb
201
223
  - spec/httparty/request/body_spec.rb