httparty 0.10.0 → 0.14.0
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +92 -0
- data/.rubocop_todo.yml +124 -0
- data/.simplecov +1 -0
- data/.travis.yml +5 -4
- data/CONTRIBUTING.md +23 -0
- data/Gemfile +9 -5
- data/Guardfile +3 -3
- data/History +109 -8
- data/README.md +21 -21
- data/Rakefile +5 -10
- data/bin/httparty +21 -14
- data/docs/README.md +100 -0
- data/examples/README.md +67 -0
- data/examples/aaws.rb +9 -9
- data/examples/basic.rb +6 -10
- data/examples/crack.rb +3 -3
- data/examples/custom_parsers.rb +1 -4
- data/examples/delicious.rb +12 -12
- data/examples/google.rb +2 -2
- data/examples/headers_and_user_agents.rb +2 -2
- data/examples/logging.rb +36 -0
- data/examples/nokogiri_html_parser.rb +0 -3
- data/examples/rescue_json.rb +17 -0
- data/examples/rubyurl.rb +3 -3
- data/examples/stackexchange.rb +24 -0
- data/examples/tripit_sign_in.rb +20 -9
- data/examples/twitter.rb +11 -11
- data/examples/whoismyrep.rb +2 -2
- data/features/command_line.feature +90 -2
- data/features/digest_authentication.feature +10 -0
- data/features/handles_compressed_responses.feature +8 -0
- data/features/handles_multiple_formats.feature +23 -0
- data/features/steps/env.rb +16 -11
- data/features/steps/httparty_response_steps.rb +40 -10
- data/features/steps/httparty_steps.rb +19 -3
- data/features/steps/mongrel_helper.rb +35 -2
- data/features/steps/remote_service_steps.rb +31 -8
- data/features/supports_read_timeout_option.feature +13 -0
- data/httparty.gemspec +9 -6
- data/lib/httparty/connection_adapter.rb +76 -11
- data/lib/httparty/cookie_hash.rb +3 -4
- data/lib/httparty/exceptions.rb +10 -4
- data/lib/httparty/hash_conversions.rb +19 -17
- data/lib/httparty/logger/apache_formatter.rb +22 -0
- data/lib/httparty/logger/curl_formatter.rb +91 -0
- data/lib/httparty/logger/logger.rb +26 -0
- data/lib/httparty/module_inheritable_attributes.rb +1 -1
- data/lib/httparty/net_digest_auth.rb +69 -18
- data/lib/httparty/parser.rb +15 -11
- data/lib/httparty/request.rb +186 -47
- data/lib/httparty/response/headers.rb +2 -2
- data/lib/httparty/response.rb +44 -9
- data/lib/httparty/version.rb +1 -1
- data/lib/httparty.rb +187 -65
- data/script/release +42 -0
- data/spec/fixtures/twitter.csv +2 -0
- data/spec/httparty/connection_adapter_spec.rb +334 -62
- data/spec/httparty/cookie_hash_spec.rb +53 -23
- data/spec/httparty/exception_spec.rb +45 -0
- data/spec/httparty/hash_conversions_spec.rb +49 -0
- data/spec/httparty/logger/apache_formatter_spec.rb +41 -0
- data/spec/httparty/logger/curl_formatter_spec.rb +119 -0
- data/spec/httparty/logger/logger_spec.rb +38 -0
- data/spec/httparty/net_digest_auth_spec.rb +148 -23
- data/spec/httparty/parser_spec.rb +48 -41
- data/spec/httparty/request_spec.rb +845 -151
- data/spec/httparty/response_spec.rb +147 -70
- data/spec/httparty/ssl_spec.rb +33 -21
- data/spec/httparty_spec.rb +337 -186
- data/spec/spec_helper.rb +38 -9
- data/spec/support/ssl_test_helper.rb +10 -10
- data/spec/support/ssl_test_server.rb +21 -21
- data/spec/support/stub_response.rb +20 -14
- data/website/index.html +3 -3
- metadata +46 -37
- data/lib/httparty/core_extensions.rb +0 -32
- data/spec/spec.opts +0 -2
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f66396072d869ad76f661789a0e9b2d66495faa2
|
4
|
+
data.tar.gz: ae8e43661459ee5bd5c9018645812ecd9500cd6b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac6a080a19674df0435a6715406b97645ed9ee2ed803b92eb3e90ade39e75ac311b3e11960d2c44d00a561720be53aa1d229f216fb40e67f4452659701005695
|
7
|
+
data.tar.gz: 7529cf1586833fef74e6e6840a8992ab6b8c8b9ff83db89c5179bf166ce21abc0868c63bd800b5f110a85f65c90472e24cc89632d9cedf0f3bae39c70c1baa6c
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
# Offense count: 963
|
4
|
+
# Cop supports --auto-correct.
|
5
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
6
|
+
Style/StringLiterals:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
# Offense count: 327
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
|
12
|
+
Style/SpaceInsideHashLiteralBraces:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
# Offense count: 33
|
16
|
+
# Cop supports --auto-correct.
|
17
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
18
|
+
Style/SpaceInsideBlockBraces:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# Offense count: 1
|
22
|
+
# Cop supports --auto-correct.
|
23
|
+
Style/SpaceBeforeSemicolon:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
# Offense count: 20
|
27
|
+
# Cop supports --auto-correct.
|
28
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
29
|
+
Style/SignalException:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# Offense count: 1
|
33
|
+
# Configuration parameters: Methods.
|
34
|
+
Style/SingleLineBlockParams:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
# Offense count: 6
|
38
|
+
# Cop supports --auto-correct.
|
39
|
+
Style/PerlBackrefs:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
# Offense count: 2
|
43
|
+
# Cop supports --auto-correct.
|
44
|
+
# Configuration parameters: AllowAsExpressionSeparator.
|
45
|
+
Style/Semicolon:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Offense count: 77
|
49
|
+
# Cop supports --auto-correct.
|
50
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
51
|
+
Style/BracesAroundHashParameters:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
# Offense count: 36
|
55
|
+
Style/Documentation:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
# Offense count: 6
|
59
|
+
# Cop supports --auto-correct.
|
60
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
61
|
+
Style/RegexpLiteral:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
# Offense count: 5
|
65
|
+
# Cop supports --auto-correct.
|
66
|
+
Style/NumericLiterals:
|
67
|
+
MinDigits: 6
|
68
|
+
|
69
|
+
# Offense count: 4
|
70
|
+
# Cop supports --auto-correct.
|
71
|
+
Lint/UnusedMethodArgument:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
# Offense count: 11
|
75
|
+
# Cop supports --auto-correct.
|
76
|
+
Lint/UnusedBlockArgument:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
# Offense count: 1
|
80
|
+
Lint/Void:
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
# Offense count: 22
|
84
|
+
# Cop supports --auto-correct.
|
85
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
86
|
+
Style/IndentHash:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
# Offense count: 7
|
90
|
+
# Configuration parameters: MinBodyLength.
|
91
|
+
Style/GuardClause:
|
92
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2015-04-24 07:22:28 +0200 using RuboCop version 0.30.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 33
|
9
|
+
Lint/AmbiguousRegexpLiteral:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
# Offense count: 1
|
13
|
+
# Configuration parameters: AlignWith, SupportedStyles.
|
14
|
+
Lint/EndAlignment:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
Lint/HandleExceptions:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# Offense count: 5
|
22
|
+
Lint/UselessAssignment:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# Offense count: 23
|
26
|
+
Metrics/AbcSize:
|
27
|
+
Max: 86
|
28
|
+
|
29
|
+
# Offense count: 1
|
30
|
+
# Configuration parameters: CountComments.
|
31
|
+
Metrics/ClassLength:
|
32
|
+
Max: 285
|
33
|
+
|
34
|
+
# Offense count: 8
|
35
|
+
Metrics/CyclomaticComplexity:
|
36
|
+
Max: 17
|
37
|
+
|
38
|
+
# Offense count: 332
|
39
|
+
# Configuration parameters: AllowURI, URISchemes.
|
40
|
+
Metrics/LineLength:
|
41
|
+
Max: 266
|
42
|
+
|
43
|
+
# Offense count: 17
|
44
|
+
# Configuration parameters: CountComments.
|
45
|
+
Metrics/MethodLength:
|
46
|
+
Max: 39
|
47
|
+
|
48
|
+
# Offense count: 8
|
49
|
+
Metrics/PerceivedComplexity:
|
50
|
+
Max: 20
|
51
|
+
|
52
|
+
# Offense count: 1
|
53
|
+
Style/AccessorMethodName:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Offense count: 1
|
57
|
+
Style/AsciiComments:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
# Offense count: 14
|
61
|
+
# Cop supports --auto-correct.
|
62
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
63
|
+
Style/BlockDelimiters:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
# Offense count: 2
|
67
|
+
Style/CaseEquality:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
# Offense count: 3
|
71
|
+
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
|
72
|
+
Style/CaseIndentation:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
# Offense count: 4
|
76
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
77
|
+
Style/ClassAndModuleChildren:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
# Offense count: 7
|
81
|
+
Style/ConstantName:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
# Offense count: 2
|
85
|
+
Style/EachWithObject:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
# Offense count: 2
|
89
|
+
# Cop supports --auto-correct.
|
90
|
+
Style/ElseAlignment:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
# Offense count: 3
|
94
|
+
# Cop supports --auto-correct.
|
95
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
96
|
+
Style/FirstParameterIndentation:
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
# Offense count: 2
|
100
|
+
# Cop supports --auto-correct.
|
101
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
102
|
+
Style/HashSyntax:
|
103
|
+
Enabled: false
|
104
|
+
|
105
|
+
# Offense count: 7
|
106
|
+
# Cop supports --auto-correct.
|
107
|
+
# Configuration parameters: MaxLineLength.
|
108
|
+
Style/IfUnlessModifier:
|
109
|
+
Enabled: false
|
110
|
+
|
111
|
+
# Offense count: 11
|
112
|
+
# Cop supports --auto-correct.
|
113
|
+
Style/Lambda:
|
114
|
+
Enabled: false
|
115
|
+
|
116
|
+
# Offense count: 1
|
117
|
+
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
118
|
+
Style/Next:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
# Offense count: 2
|
122
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
123
|
+
Style/RaiseArgs:
|
124
|
+
Enabled: false
|
data/.simplecov
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SimpleCov.start "test_frameworks"
|
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
* Contributions will not be accepted without tests.
|
4
|
+
* Please post unconfirmed bugs to the mailing list first: https://groups.google.com/forum/#!forum/httparty-gem
|
5
|
+
* Don't change the version. The maintainers will handle that when they release.
|
6
|
+
* Always provide as much information and reproducibility as possible when filing an issue or submitting a pull request.
|
7
|
+
|
8
|
+
## Workflow
|
9
|
+
|
10
|
+
* Fork the project.
|
11
|
+
* Run `bundle`
|
12
|
+
* Run `bundle exec rake`
|
13
|
+
* Make your feature addition or bug fix.
|
14
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
15
|
+
* Run `bundle exec rake` (No, REALLY :))
|
16
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
|
17
|
+
* Send me a pull request. Bonus points for topic branches.
|
18
|
+
|
19
|
+
## Help and Docs
|
20
|
+
|
21
|
+
* https://groups.google.com/forum/#!forum/httparty-gem
|
22
|
+
* http://stackoverflow.com/questions/tagged/httparty
|
23
|
+
* http://rdoc.info/projects/jnunemaker/httparty
|
data/Gemfile
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
4
|
gem 'rake'
|
5
|
-
gem '
|
6
|
-
gem 'fakeweb', '~> 1.2'
|
7
|
-
gem 'rspec', '~> 1.3'
|
5
|
+
gem 'fakeweb', '~> 1.3'
|
8
6
|
gem 'mongrel', '1.2.0.pre2'
|
9
|
-
gem 'multi_json', '~> 1.3'
|
10
7
|
|
11
8
|
group :development do
|
12
9
|
gem 'guard'
|
13
10
|
gem 'guard-rspec'
|
14
11
|
gem 'guard-bundler'
|
15
12
|
end
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'rspec', '~> 3.4'
|
16
|
+
gem 'simplecov', require: false
|
17
|
+
gem 'aruba'
|
18
|
+
gem 'cucumber', '~> 2.3'
|
19
|
+
end
|
data/Guardfile
CHANGED
data/History
CHANGED
@@ -1,3 +1,105 @@
|
|
1
|
+
== 0.14.0
|
2
|
+
* [added status predicate methods to Response#respond_to?](https://github.com/jnunemaker/httparty/pull/482)
|
3
|
+
* [allow empty array to be used as param](https://github.com/jnunemaker/httparty/pull/477)
|
4
|
+
* [add support for MKCOL method](https://github.com/jnunemaker/httparty/pull/465)
|
5
|
+
* [remove json gem from gemspec](https://github.com/jnunemaker/httparty/pull/464)
|
6
|
+
* [stop mutating cookie hash](https://github.com/jnunemaker/httparty/pull/460)
|
7
|
+
* [optional raising exception on certain status codes](https://github.com/jnunemaker/httparty/pull/455)
|
8
|
+
|
9
|
+
== 0.13.7 aka "party not as hard"
|
10
|
+
* remove post install emoji as it caused installation issues for some people
|
11
|
+
|
12
|
+
== 0.13.6
|
13
|
+
* avoid calling String#strip on invalid Strings
|
14
|
+
* preserve request method on 307 and 308 redirects
|
15
|
+
* output version with --version for command line bin
|
16
|
+
* maintain head request method across redirects by default
|
17
|
+
* add support for RFC2617 MD5-sess algorithm type
|
18
|
+
* add party popper emoji to post install message
|
19
|
+
|
20
|
+
== 0.13.5
|
21
|
+
* allow setting a custom URI adapter
|
22
|
+
|
23
|
+
== 0.13.4
|
24
|
+
* correct redirect url for redirect paths without leading slash
|
25
|
+
* remove core_extensions.rb as backwards compat for ruby 1.8 not needed
|
26
|
+
* replace URI.encode with ERB::Util.url_encode
|
27
|
+
* allow the response to be tapped
|
28
|
+
|
29
|
+
== 0.13.3
|
30
|
+
* minor improvement
|
31
|
+
* added option to allow for streaming large files without loading them into memory (672cdae)
|
32
|
+
|
33
|
+
== 0.13.2
|
34
|
+
* minor improvement
|
35
|
+
* [Set correct path on redirect to filename](https://github.com/jnunemaker/httparty/pull/337)
|
36
|
+
* ensure logger works with curl format
|
37
|
+
|
38
|
+
== 0.13.1 2014-04-08
|
39
|
+
* new
|
40
|
+
* [Added ability to specify a body_stream in HttpRequest](https://github.com/jnunemaker/httparty/pull/275)
|
41
|
+
* [Added read_timeout and open_timeout options](https://github.com/jnunemaker/httparty/pull/278)
|
42
|
+
* change
|
43
|
+
* [Initialize HTTParty requests with an URI object and a String](https://github.com/jnunemaker/httparty/pull/274)
|
44
|
+
* minor improvement
|
45
|
+
* [Add stackexchange API example](https://github.com/jnunemaker/httparty/pull/280)
|
46
|
+
|
47
|
+
== 0.13.0 2014-02-14
|
48
|
+
* new
|
49
|
+
* [Add CSV support](https://github.com/jnunemaker/httparty/pull/269)
|
50
|
+
* [Allows PKCS12 client certificates](https://github.com/jnunemaker/httparty/pull/246)
|
51
|
+
* bug fix
|
52
|
+
* [Digest auth no longer fails when multiple headers are sent by the server](https://github.com/jnunemaker/httparty/pull/272)
|
53
|
+
* [Use 'Basement.copy' when calling 'HTTParty.copy'](https://github.com/jnunemaker/httparty/pull/268)
|
54
|
+
* [No longer appends ampersand when queries are embedded in paths](https://github.com/jnunemaker/httparty/pull/252)
|
55
|
+
* change
|
56
|
+
* [Merge - instead of overwrite - default headers with request provided headers](https://github.com/jnunemaker/httparty/pull/270)
|
57
|
+
* [Modernize respond_to implementations to support second param](https://github.com/jnunemaker/httparty/pull/264)
|
58
|
+
* [Sort query parameters by key before processing](https://github.com/jnunemaker/httparty/pull/245)
|
59
|
+
* minor improvement
|
60
|
+
* [Add HTTParty::Error base class](https://github.com/jnunemaker/httparty/pull/260)
|
61
|
+
|
62
|
+
== 0.12.0 2013-10-10
|
63
|
+
* new
|
64
|
+
* [Added initial logging support](https://github.com/jnunemaker/httparty/pull/243)
|
65
|
+
* [Add support for local host and port binding](https://github.com/jnunemaker/httparty/pull/238)
|
66
|
+
* [content_type_charset_support](https://github.com/jnunemaker/httparty/commit/82e351f0904e8ecc856015ff2854698a2ca47fbc)
|
67
|
+
* bug fix
|
68
|
+
* [No longer attempt to decompress the body on HEAD requests](https://github.com/jnunemaker/httparty/commit/f2b8cc3d49e0e9363d7054b14f30c340d7b8e7f1)
|
69
|
+
* [Adding java check in aliasing of multiple choices](https://github.com/jnunemaker/httparty/pull/204/commits)
|
70
|
+
* change
|
71
|
+
* [MIME-type files of javascript are returned as a string instead of JSON](https://github.com/jnunemaker/httparty/pull/239)
|
72
|
+
* [Made SSL connections use the system certificate store by default](https://github.com/jnunemaker/httparty/pull/226)
|
73
|
+
* [Do not pass proxy options to Net::HTTP connection if not specified](https://github.com/jnunemaker/httparty/pull/222)
|
74
|
+
* [Replace multi_json with stdlib json](https://github.com/jnunemaker/httparty/pull/214)
|
75
|
+
* [Require Ruby >= 1.9.3]
|
76
|
+
* [Response returns array of returned cookie strings](https://github.com/jnunemaker/httparty/pull/218)
|
77
|
+
* [Allow '=' within value of a cookie]
|
78
|
+
* minor improvements
|
79
|
+
* [Improve documentation of ssl_ca_file, ssl_ca_path](https://github.com/jnunemaker/httparty/pull/223)
|
80
|
+
* [Fix example URLs](https://github.com/jnunemaker/httparty/pull/232)
|
81
|
+
|
82
|
+
== 0.11.0 2013-04-10
|
83
|
+
* new
|
84
|
+
* [Add COPY http request handling](https://github.com/jnunemaker/httparty/pull/190)
|
85
|
+
* [Ruby 2.0 tests](https://github.com/jnunemaker/httparty/pull/194)
|
86
|
+
* [Ruby >= 2.0.0 support both multiple_choice? and multiple_choices?]
|
87
|
+
* bug fix
|
88
|
+
* [Maintain blocks passed to 'perform' in redirects](https://github.com/jnunemaker/httparty/pull/191)
|
89
|
+
* [Fixed nc value being quoted, this was against spec](https://github.com/jnunemaker/httparty/pull/196)
|
90
|
+
* [Request#uri no longer duplicates non-relative-path params](https://github.com/jnunemaker/httparty/pull/189)
|
91
|
+
* change
|
92
|
+
* [Client-side-only cookie attributes are removed: case-insensitive](https://github.com/jnunemaker/httparty/pull/188)
|
93
|
+
|
94
|
+
== 0.10.2 2013-01-26
|
95
|
+
* bug fix
|
96
|
+
* [hash_conversions misnamed variable](https://github.com/jnunemaker/httparty/pull/187)
|
97
|
+
|
98
|
+
== 0.10.1 2013-01-26
|
99
|
+
* new
|
100
|
+
* [Added support for MOVE requests](https://github.com/jnunemaker/httparty/pull/183)
|
101
|
+
* [Bump multi xml version](https://github.com/jnunemaker/httparty/pull/181)
|
102
|
+
|
1
103
|
== 0.10.0 2013-01-10
|
2
104
|
* changes
|
3
105
|
* removed yaml support because of security risk (see rails yaml issues)
|
@@ -6,7 +108,6 @@
|
|
6
108
|
* new
|
7
109
|
* [support for connection adapters](https://github.com/jnunemaker/httparty/pull/157)
|
8
110
|
* [allow ssl_version on ruby 1.9](https://github.com/jnunemaker/httparty/pull/159)
|
9
|
-
|
10
111
|
* bug fixes
|
11
112
|
* [don't treat port 4430 as ssl](https://github.com/jnunemaker/httparty/commit/a296b1c97f83d7dcc6ef85720a43664c265685ac)
|
12
113
|
* [deep clone default options](https://github.com/jnunemaker/httparty/commit/f74227d30f9389b4b23a888c9af49fb9b8248e1f)
|
@@ -161,7 +262,7 @@
|
|
161
262
|
|
162
263
|
* minor enhancements
|
163
264
|
* Timeout option added; will raise a Timeout::Error after the timeout has elapsed (attack). Closes #17
|
164
|
-
HTTParty.get "http://github.com", :
|
265
|
+
HTTParty.get "http://github.com", timeout: 1
|
165
266
|
* Building gem with Jeweler
|
166
267
|
|
167
268
|
== 0.4.4 2009-07-19
|
@@ -276,20 +377,20 @@
|
|
276
377
|
== 0.1.3 2008-08-22
|
277
378
|
|
278
379
|
* 3 major enhancements:
|
279
|
-
|
280
|
-
|
281
|
-
|
380
|
+
* Added http_proxy key for setting proxy server and port (francxk@gmail.com)
|
381
|
+
* Now raises exception when http error occurs (francxk@gmail.com)
|
382
|
+
* Changed auto format detection from file extension to response content type (Jay Pignata)
|
282
383
|
|
283
384
|
== 0.1.2 2008-08-09
|
284
385
|
|
285
386
|
* 1 major enhancement:
|
286
|
-
|
387
|
+
* default_params were not being appended to query string if option[:query] was blank
|
287
388
|
|
288
389
|
== 0.1.1 2008-07-30
|
289
390
|
|
290
391
|
* 2 major enhancement:
|
291
|
-
|
292
|
-
|
392
|
+
* Added :basic_auth key for options when making a request
|
393
|
+
* :query and :body both now work with query string or hash
|
293
394
|
|
294
395
|
== 0.1.0 2008-07-27
|
295
396
|
|
data/README.md
CHANGED
@@ -10,44 +10,39 @@ gem install httparty
|
|
10
10
|
|
11
11
|
## Requirements
|
12
12
|
|
13
|
-
*
|
13
|
+
* Ruby 1.9.3 or higher
|
14
|
+
* multi_xml
|
14
15
|
* You like to party!
|
15
16
|
|
16
17
|
## Examples
|
17
18
|
|
18
19
|
```ruby
|
19
20
|
# Use the class methods to get down to business quickly
|
20
|
-
response = HTTParty.get('http://
|
21
|
-
puts response.body, response.code, response.message, response.headers.inspect
|
21
|
+
response = HTTParty.get('http://api.stackexchange.com/2.2/questions?site=stackoverflow')
|
22
22
|
|
23
|
-
response.
|
24
|
-
puts item['user']['screen_name']
|
25
|
-
end
|
23
|
+
puts response.body, response.code, response.message, response.headers.inspect
|
26
24
|
|
27
25
|
# Or wrap things up in your own class
|
28
|
-
class
|
26
|
+
class StackExchange
|
29
27
|
include HTTParty
|
30
|
-
base_uri '
|
28
|
+
base_uri 'api.stackexchange.com'
|
31
29
|
|
32
|
-
def initialize(
|
33
|
-
@
|
30
|
+
def initialize(service, page)
|
31
|
+
@options = { query: {site: service, page: page} }
|
34
32
|
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
def timeline(which=:friends, options={})
|
39
|
-
options.merge!({:basic_auth => @auth})
|
40
|
-
self.class.get("/statuses/#{which}_timeline.json", options)
|
34
|
+
def questions
|
35
|
+
self.class.get("/2.2/questions", @options)
|
41
36
|
end
|
42
37
|
|
43
|
-
def
|
44
|
-
|
45
|
-
self.class.post('/statuses/update.json', options)
|
38
|
+
def users
|
39
|
+
self.class.get("/2.2/users", @options)
|
46
40
|
end
|
47
41
|
end
|
48
42
|
|
49
|
-
|
50
|
-
|
43
|
+
stack_exchange = StackExchange.new("stackoverflow", 1)
|
44
|
+
puts stack_exchange.questions
|
45
|
+
puts stack_exchange.users
|
51
46
|
```
|
52
47
|
|
53
48
|
See the [examples directory](http://github.com/jnunemaker/httparty/tree/master/examples) for even more goodies.
|
@@ -62,18 +57,23 @@ formatted XML or JSON. Execute `httparty --help` for all the
|
|
62
57
|
options. Below is an example of how easy it is.
|
63
58
|
|
64
59
|
```
|
65
|
-
httparty "
|
60
|
+
httparty "https://api.stackexchange.com/2.2/questions?site=stackoverflow"
|
66
61
|
```
|
67
62
|
|
68
63
|
## Help and Docs
|
69
64
|
|
65
|
+
* [Docs](docs/)
|
70
66
|
* https://groups.google.com/forum/#!forum/httparty-gem
|
71
67
|
* http://rdoc.info/projects/jnunemaker/httparty
|
68
|
+
* http://stackoverflow.com/questions/tagged/httparty
|
72
69
|
|
73
70
|
## Contributing
|
74
71
|
|
75
72
|
* Fork the project.
|
73
|
+
* Run `bundle`
|
74
|
+
* Run `bundle exec rake`
|
76
75
|
* Make your feature addition or bug fix.
|
77
76
|
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
77
|
+
* Run `bundle exec rake` (No, REALLY :))
|
78
78
|
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
|
79
79
|
* Send me a pull request. Bonus points for topic branches.
|
data/Rakefile
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
6
|
-
spec.ruby_opts << '-rubygems'
|
7
|
-
spec.libs << 'lib' << 'spec'
|
8
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
9
|
-
spec.spec_opts = ['--options', 'spec/spec.opts']
|
1
|
+
begin
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
RSpec::Core::RakeTask.new(:spec)
|
4
|
+
rescue LoadError
|
10
5
|
end
|
11
6
|
|
12
7
|
require 'cucumber/rake/task'
|
13
8
|
Cucumber::Rake::Task.new(:features)
|
14
9
|
|
15
|
-
task :
|
10
|
+
task default: [:spec, :features]
|
data/bin/httparty
CHANGED
@@ -3,22 +3,22 @@
|
|
3
3
|
require "optparse"
|
4
4
|
require "pp"
|
5
5
|
|
6
|
-
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "/../lib"))
|
7
7
|
require "httparty"
|
8
8
|
|
9
9
|
opts = {
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
10
|
+
action: :get,
|
11
|
+
headers: {},
|
12
|
+
verbose: false
|
13
13
|
}
|
14
14
|
|
15
15
|
OptionParser.new do |o|
|
16
|
-
o.banner = "USAGE: #{$
|
16
|
+
o.banner = "USAGE: #{$PROGRAM_NAME} [options] [url]"
|
17
17
|
|
18
18
|
o.on("-f",
|
19
19
|
"--format [FORMAT]",
|
20
|
-
"Output format to use instead of pretty-print ruby: "
|
21
|
-
"plain, json or xml") do |f|
|
20
|
+
"Output format to use instead of pretty-print ruby: " \
|
21
|
+
"plain, csv, json or xml") do |f|
|
22
22
|
opts[:output_format] = f.downcase.to_sym
|
23
23
|
end
|
24
24
|
|
@@ -51,7 +51,7 @@ OptionParser.new do |o|
|
|
51
51
|
o.on("-u", "--user [CREDS]", "Use basic authentication. Value should be user:password") do |u|
|
52
52
|
abort "Invalid credentials format. Must be user:password" unless u =~ /.*:.+/
|
53
53
|
user, password = u.split(':')
|
54
|
-
opts[:basic_auth] = { :
|
54
|
+
opts[:basic_auth] = { username: user, password: password }
|
55
55
|
end
|
56
56
|
|
57
57
|
o.on("-r", "--response-code", "Command fails if response code >= 400") do
|
@@ -62,18 +62,22 @@ OptionParser.new do |o|
|
|
62
62
|
puts o
|
63
63
|
exit
|
64
64
|
end
|
65
|
-
end.parse!
|
66
65
|
|
66
|
+
o.on("--version", "Show HTTParty version") do |ver|
|
67
|
+
puts "Version: #{HTTParty::VERSION}"
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
end.parse!
|
67
71
|
|
68
72
|
if ARGV.empty?
|
69
73
|
STDERR.puts "You need to provide a URL"
|
70
|
-
STDERR.puts "USAGE: #{$
|
74
|
+
STDERR.puts "USAGE: #{$PROGRAM_NAME} [options] [url]"
|
71
75
|
end
|
72
76
|
|
73
77
|
def dump_headers(response)
|
74
78
|
resp_type = Net::HTTPResponse::CODE_TO_OBJ[response.code.to_s]
|
75
79
|
puts "#{response.code} #{resp_type.to_s.sub(/^Net::HTTP/, '')}"
|
76
|
-
response.headers.each do |n,v|
|
80
|
+
response.headers.each do |n, v|
|
77
81
|
puts "#{n}: #{v}"
|
78
82
|
end
|
79
83
|
puts
|
@@ -81,7 +85,7 @@ end
|
|
81
85
|
|
82
86
|
if opts[:verbose]
|
83
87
|
puts "#{opts[:action].to_s.upcase} #{ARGV.first}"
|
84
|
-
opts[:headers].each do |n,v|
|
88
|
+
opts[:headers].each do |n, v|
|
85
89
|
puts "#{n}: #{v}"
|
86
90
|
end
|
87
91
|
puts
|
@@ -99,14 +103,17 @@ else
|
|
99
103
|
when :json
|
100
104
|
begin
|
101
105
|
require 'json'
|
102
|
-
puts JSON.pretty_generate(response
|
106
|
+
puts JSON.pretty_generate(response)
|
103
107
|
rescue LoadError
|
104
|
-
puts YAML.dump(response
|
108
|
+
puts YAML.dump(response)
|
105
109
|
end
|
106
110
|
when :xml
|
107
111
|
require 'rexml/document'
|
108
112
|
REXML::Document.new(response.body).write(STDOUT, 2)
|
109
113
|
puts
|
114
|
+
when :csv
|
115
|
+
require 'csv'
|
116
|
+
puts CSV.parse(response.body).map(&:to_s)
|
110
117
|
else
|
111
118
|
puts response
|
112
119
|
end
|