httparty 0.14.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/.editorconfig +18 -0
  3. data/.github/workflows/ci.yml +26 -0
  4. data/.gitignore +3 -0
  5. data/.rubocop_todo.yml +1 -1
  6. data/{History → Changelog.md} +222 -63
  7. data/Gemfile +8 -1
  8. data/Guardfile +3 -2
  9. data/README.md +8 -8
  10. data/bin/httparty +3 -1
  11. data/docs/README.md +128 -37
  12. data/examples/README.md +34 -12
  13. data/examples/aaws.rb +7 -3
  14. data/examples/body_stream.rb +14 -0
  15. data/examples/crack.rb +1 -1
  16. data/examples/custom_parsers.rb +5 -1
  17. data/examples/delicious.rb +4 -4
  18. data/examples/headers_and_user_agents.rb +7 -3
  19. data/examples/idn.rb +10 -0
  20. data/examples/logging.rb +4 -4
  21. data/examples/microsoft_graph.rb +52 -0
  22. data/examples/multipart.rb +22 -0
  23. data/examples/peer_cert.rb +9 -0
  24. data/examples/stackexchange.rb +1 -1
  25. data/examples/stream_download.rb +26 -0
  26. data/examples/tripit_sign_in.rb +1 -1
  27. data/examples/twitter.rb +2 -2
  28. data/examples/whoismyrep.rb +1 -1
  29. data/httparty.gemspec +7 -4
  30. data/lib/httparty/connection_adapter.rb +73 -16
  31. data/lib/httparty/cookie_hash.rb +10 -8
  32. data/lib/httparty/decompressor.rb +102 -0
  33. data/lib/httparty/exceptions.rb +4 -1
  34. data/lib/httparty/hash_conversions.rb +30 -12
  35. data/lib/httparty/headers_processor.rb +32 -0
  36. data/lib/httparty/logger/apache_formatter.rb +31 -6
  37. data/lib/httparty/logger/curl_formatter.rb +9 -7
  38. data/lib/httparty/logger/logger.rb +5 -1
  39. data/lib/httparty/logger/logstash_formatter.rb +61 -0
  40. data/lib/httparty/module_inheritable_attributes.rb +6 -4
  41. data/lib/httparty/net_digest_auth.rb +19 -19
  42. data/lib/httparty/parser.rb +25 -14
  43. data/lib/httparty/request/body.rb +105 -0
  44. data/lib/httparty/request/multipart_boundary.rb +13 -0
  45. data/lib/httparty/request.rb +141 -110
  46. data/lib/httparty/response/headers.rb +23 -19
  47. data/lib/httparty/response.rb +81 -22
  48. data/lib/httparty/response_fragment.rb +21 -0
  49. data/lib/httparty/text_encoder.rb +72 -0
  50. data/lib/httparty/utils.rb +13 -0
  51. data/lib/httparty/version.rb +3 -1
  52. data/lib/httparty.rb +79 -31
  53. data/website/css/common.css +1 -1
  54. metadata +39 -106
  55. data/.simplecov +0 -1
  56. data/.travis.yml +0 -9
  57. data/features/basic_authentication.feature +0 -20
  58. data/features/command_line.feature +0 -95
  59. data/features/deals_with_http_error_codes.feature +0 -26
  60. data/features/digest_authentication.feature +0 -30
  61. data/features/handles_compressed_responses.feature +0 -27
  62. data/features/handles_multiple_formats.feature +0 -57
  63. data/features/steps/env.rb +0 -27
  64. data/features/steps/httparty_response_steps.rb +0 -56
  65. data/features/steps/httparty_steps.rb +0 -43
  66. data/features/steps/mongrel_helper.rb +0 -127
  67. data/features/steps/remote_service_steps.rb +0 -92
  68. data/features/supports_read_timeout_option.feature +0 -13
  69. data/features/supports_redirection.feature +0 -22
  70. data/features/supports_timeout_option.feature +0 -13
  71. data/spec/fixtures/delicious.xml +0 -23
  72. data/spec/fixtures/empty.xml +0 -0
  73. data/spec/fixtures/google.html +0 -3
  74. data/spec/fixtures/ssl/generate.sh +0 -29
  75. data/spec/fixtures/ssl/generated/1fe462c2.0 +0 -16
  76. data/spec/fixtures/ssl/generated/bogushost.crt +0 -13
  77. data/spec/fixtures/ssl/generated/ca.crt +0 -16
  78. data/spec/fixtures/ssl/generated/ca.key +0 -15
  79. data/spec/fixtures/ssl/generated/selfsigned.crt +0 -14
  80. data/spec/fixtures/ssl/generated/server.crt +0 -13
  81. data/spec/fixtures/ssl/generated/server.key +0 -15
  82. data/spec/fixtures/ssl/openssl-exts.cnf +0 -9
  83. data/spec/fixtures/twitter.csv +0 -2
  84. data/spec/fixtures/twitter.json +0 -1
  85. data/spec/fixtures/twitter.xml +0 -403
  86. data/spec/fixtures/undefined_method_add_node_for_nil.xml +0 -2
  87. data/spec/httparty/connection_adapter_spec.rb +0 -495
  88. data/spec/httparty/cookie_hash_spec.rb +0 -100
  89. data/spec/httparty/exception_spec.rb +0 -45
  90. data/spec/httparty/hash_conversions_spec.rb +0 -49
  91. data/spec/httparty/logger/apache_formatter_spec.rb +0 -41
  92. data/spec/httparty/logger/curl_formatter_spec.rb +0 -119
  93. data/spec/httparty/logger/logger_spec.rb +0 -38
  94. data/spec/httparty/net_digest_auth_spec.rb +0 -240
  95. data/spec/httparty/parser_spec.rb +0 -173
  96. data/spec/httparty/request_spec.rb +0 -1183
  97. data/spec/httparty/response_spec.rb +0 -291
  98. data/spec/httparty/ssl_spec.rb +0 -74
  99. data/spec/httparty_spec.rb +0 -872
  100. data/spec/spec_helper.rb +0 -59
  101. data/spec/support/ssl_test_helper.rb +0 -47
  102. data/spec/support/ssl_test_server.rb +0 -80
  103. data/spec/support/stub_response.rb +0 -49
@@ -1,26 +0,0 @@
1
- Feature: Deals with HTTP error codes
2
-
3
- As a developer
4
- I want to be informed of non-successful responses
5
- Because sometimes thing explode
6
- And I should probably know what happened
7
-
8
- Scenario: A response of '404 - Not Found'
9
- Given a remote service that returns a 404 status code
10
- And that service is accessed at the path '/404_service.html'
11
- When I call HTTParty#get with '/404_service.html'
12
- Then it should return a response with a 404 response code
13
-
14
- Scenario: A response of '500 - Internal Server Error'
15
- Given a remote service that returns a 500 status code
16
- And that service is accessed at the path '/500_service.html'
17
- When I call HTTParty#get with '/500_service.html'
18
- Then it should return a response with a 500 response code
19
-
20
- Scenario: A non-successful response where I need the body
21
- Given a remote service that returns a 400 status code
22
- And the response from the service has a body of 'Bad response'
23
- And that service is accessed at the path '/400_service.html'
24
- When I call HTTParty#get with '/400_service.html'
25
- Then it should return a response with a 400 response code
26
- And the return value should match 'Bad response'
@@ -1,30 +0,0 @@
1
- Feature: Digest Authentication
2
-
3
- As a developer
4
- I want to be able to use a service that requires Digest Authentication
5
- Because that is not an uncommon requirement
6
-
7
- Scenario: Passing no credentials to a page requiring Digest Authentication
8
- Given a restricted page at '/digest_auth.html'
9
- When I call HTTParty#get with '/digest_auth.html'
10
- Then it should return a response with a 401 response code
11
-
12
- Scenario: Passing proper credentials to a page requiring Digest Authentication
13
- Given a remote service that returns 'Digest Authenticated Page'
14
- And that service is accessed at the path '/digest_auth.html'
15
- And that service is protected by Digest Authentication
16
- And that service requires the username 'jcash' with the password 'maninblack'
17
- When I call HTTParty#get with '/digest_auth.html' and a digest_auth hash:
18
- | username | password |
19
- | jcash | maninblack |
20
- Then the return value should match 'Digest Authenticated Page'
21
-
22
- Scenario: Passing proper credentials to a page requiring Digest Authentication using md5-sess algorithm
23
- Given a remote service that returns 'Digest Authenticated Page Using MD5-sess'
24
- And that service is accessed at the path '/digest_auth.html'
25
- And that service is protected by MD5-sess Digest Authentication
26
- And that service requires the username 'jcash' with the password 'maninblack'
27
- When I call HTTParty#get with '/digest_auth.html' and a digest_auth hash:
28
- | username | password |
29
- | jcash | maninblack |
30
- Then the return value should match 'Digest Authenticated Page Using MD5-sess'
@@ -1,27 +0,0 @@
1
- Feature: Handles Compressed Responses
2
-
3
- In order to save bandwidth
4
- As a developer
5
- I want to uncompress compressed responses
6
-
7
- Scenario: Supports deflate encoding
8
- Given a remote deflate service
9
- And the response from the service has a body of '<h1>Some HTML</h1>'
10
- And that service is accessed at the path '/deflate_service.html'
11
- When I call HTTParty#get with '/deflate_service.html'
12
- Then the return value should match '<h1>Some HTML</h1>'
13
-
14
- Scenario: Supports gzip encoding
15
- Given a remote gzip service
16
- And the response from the service has a body of '<h1>Some HTML</h1>'
17
- And that service is accessed at the path '/gzip_service.html'
18
- When I call HTTParty#get with '/gzip_service.html'
19
- Then the return value should match '<h1>Some HTML</h1>'
20
-
21
- Scenario: Supports HEAD request with gzip encoding
22
- Given a remote gzip service
23
- And that service is accessed at the path '/gzip_head.gz.js'
24
- When I call HTTParty#head with '/gzip_head.gz.js'
25
- Then it should return a response with a 200 response code
26
- Then it should return a response with a gzip content-encoding
27
- Then it should return a response with a blank body
@@ -1,57 +0,0 @@
1
- Feature: Handles Multiple Formats
2
-
3
- As a developer
4
- I want to be able to consume remote services of many different formats
5
- And I want those formats to be automatically detected and handled
6
- Because web services take many forms
7
- And I don't want to have to do any extra work
8
-
9
- Scenario: An HTML service
10
- Given a remote service that returns '<h1>Some HTML</h1>'
11
- And that service is accessed at the path '/html_service.html'
12
- And the response from the service has a Content-Type of 'text/html'
13
- When I call HTTParty#get with '/html_service.html'
14
- Then it should return a String
15
- And the return value should match '<h1>Some HTML</h1>'
16
-
17
- Scenario: A CSV service
18
- Given a remote service that returns:
19
- """
20
- "Last Name","Name"
21
- "jennings","waylon"
22
- "cash","johnny"
23
- """
24
- And that service is accessed at the path '/service.csv'
25
- And the response from the service has a Content-Type of 'application/csv'
26
- When I call HTTParty#get with '/service.csv'
27
- Then it should return an Array equaling:
28
- | Last Name | Name |
29
- | jennings | waylon |
30
- | cash | johnny |
31
-
32
- Scenario: A JSON service
33
- Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }'
34
- And that service is accessed at the path '/service.json'
35
- And the response from the service has a Content-Type of 'application/json'
36
- When I call HTTParty#get with '/service.json'
37
- Then it should return a Hash equaling:
38
- | key | value |
39
- | jennings | waylon |
40
- | cash | johnny |
41
-
42
- Scenario: An XML Service
43
- Given a remote service that returns '<singer>waylon jennings</singer>'
44
- And that service is accessed at the path '/service.xml'
45
- And the response from the service has a Content-Type of 'text/xml'
46
- When I call HTTParty#get with '/service.xml'
47
- Then it should return a Hash equaling:
48
- | key | value |
49
- | singer | waylon jennings |
50
-
51
- Scenario: A Javascript remote file
52
- Given a remote service that returns '$(function() { alert("hi"); });'
53
- And that service is accessed at the path '/service.js'
54
- And the response from the service has a Content-Type of 'application/javascript'
55
- When I call HTTParty#get with '/service.js'
56
- Then it should return a String
57
- And the return value should match '$(function() { alert("hi"); });'
@@ -1,27 +0,0 @@
1
- require 'mongrel'
2
- require './lib/httparty'
3
- require 'rspec/expectations'
4
- require 'aruba/cucumber'
5
-
6
- def run_server(port)
7
- @host_and_port = "0.0.0.0:#{port}"
8
- @server = Mongrel::HttpServer.new("0.0.0.0", port)
9
- @server.run
10
- @request_options = {}
11
- end
12
-
13
- def new_port
14
- server = TCPServer.new('0.0.0.0', nil)
15
- port = server.addr[1]
16
- ensure
17
- server.close
18
- end
19
-
20
- Before('~@command_line') do
21
- port = ENV["HTTPARTY_PORT"] || new_port
22
- run_server(port)
23
- end
24
-
25
- After do
26
- @server.stop if @server
27
- end
@@ -1,56 +0,0 @@
1
- # Not needed anymore in ruby 2.0, but needed to resolve constants
2
- # in nested namespaces. This is taken from rails :)
3
- def constantize(camel_cased_word)
4
- names = camel_cased_word.split('::')
5
- names.shift if names.empty? || names.first.empty?
6
-
7
- constant = Object
8
- names.each do |name|
9
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
10
- end
11
- constant
12
- end
13
-
14
- Then /it should return an? ([\w\:]+)$/ do |class_string|
15
- expect(@response_from_httparty.parsed_response).to be_a(Object.const_get(class_string))
16
- end
17
-
18
- Then /the return value should match '(.*)'/ do |expected_text|
19
- expect(@response_from_httparty.parsed_response).to eq(expected_text)
20
- end
21
-
22
- Then /it should return a Hash equaling:/ do |hash_table|
23
- expect(@response_from_httparty.parsed_response).to be_a(Hash)
24
- expect(@response_from_httparty.keys.length).to eq(hash_table.rows.length)
25
- hash_table.hashes.each do |pair|
26
- key, value = pair["key"], pair["value"]
27
- expect(@response_from_httparty.keys).to include(key)
28
- expect(@response_from_httparty[key]).to eq(value)
29
- end
30
- end
31
-
32
- Then /it should return an Array equaling:/ do |array|
33
- expect(@response_from_httparty.parsed_response).to be_a(Array)
34
- expect(@response_from_httparty.parsed_response).to eq(array.raw)
35
- end
36
-
37
- Then /it should return a response with a (\d+) response code/ do |code|
38
- expect(@response_from_httparty.code).to eq(code.to_i)
39
- end
40
-
41
- Then /it should return a response with a (.*) content\-encoding$/ do |content_type|
42
- expect(@response_from_httparty.headers['content-encoding']).to eq('gzip')
43
- end
44
-
45
- Then /it should return a response with a blank body$/ do
46
- expect(@response_from_httparty.body).to be_nil
47
- end
48
-
49
- Then /it should raise (?:an|a) ([\w:]+) exception/ do |exception|
50
- expect(@exception_from_httparty).to_not be_nil
51
- expect(@exception_from_httparty).to be_a constantize(exception)
52
- end
53
-
54
- Then /it should not raise (?:an|a) ([\w:]+) exception/ do |exception|
55
- expect(@exception_from_httparty).to be_nil
56
- end
@@ -1,43 +0,0 @@
1
- When /^I set my HTTParty timeout option to (\d+)$/ do |timeout|
2
- @request_options[:timeout] = timeout.to_i
3
- end
4
-
5
- When /^I set my HTTParty open_timeout option to (\d+)$/ do |timeout|
6
- @request_options[:open_timeout] = timeout.to_i
7
- end
8
-
9
- When /^I set my HTTParty read_timeout option to (\d+)$/ do |timeout|
10
- @request_options[:read_timeout] = timeout.to_i
11
- end
12
-
13
- When /I call HTTParty#get with '(.*)'$/ do |url|
14
- begin
15
- @response_from_httparty = HTTParty.get("http://#{@host_and_port}#{url}", @request_options)
16
- rescue HTTParty::RedirectionTooDeep, Timeout::Error => e
17
- @exception_from_httparty = e
18
- end
19
- end
20
-
21
- When /^I call HTTParty#head with '(.*)'$/ do |url|
22
- begin
23
- @response_from_httparty = HTTParty.head("http://#{@host_and_port}#{url}", @request_options)
24
- rescue HTTParty::RedirectionTooDeep, Timeout::Error => e
25
- @exception_from_httparty = e
26
- end
27
- end
28
-
29
- When /I call HTTParty#get with '(.*)' and a basic_auth hash:/ do |url, auth_table|
30
- h = auth_table.hashes.first
31
- @response_from_httparty = HTTParty.get(
32
- "http://#{@host_and_port}#{url}",
33
- basic_auth: { username: h["username"], password: h["password"] }
34
- )
35
- end
36
-
37
- When /I call HTTParty#get with '(.*)' and a digest_auth hash:/ do |url, auth_table|
38
- h = auth_table.hashes.first
39
- @response_from_httparty = HTTParty.get(
40
- "http://#{@host_and_port}#{url}",
41
- digest_auth: { username: h["username"], password: h["password"] }
42
- )
43
- end
@@ -1,127 +0,0 @@
1
- require 'base64'
2
- class BasicMongrelHandler < Mongrel::HttpHandler
3
- attr_accessor :content_type, :custom_headers, :response_body, :response_code, :preprocessor, :username, :password
4
-
5
- def initialize
6
- @content_type = "text/html"
7
- @response_body = ""
8
- @response_code = 200
9
- @custom_headers = {}
10
- end
11
-
12
- def process(request, response)
13
- instance_eval(&preprocessor) if preprocessor
14
- reply_with(response, response_code, response_body)
15
- end
16
-
17
- def reply_with(response, code, response_body)
18
- response.start(code) do |head, body|
19
- head["Content-Type"] = content_type
20
- custom_headers.each { |k, v| head[k] = v }
21
- body.write(response_body)
22
- end
23
- end
24
- end
25
-
26
- class DeflateHandler < BasicMongrelHandler
27
- def process(request, response)
28
- response.start do |head, body|
29
- head['Content-Encoding'] = 'deflate'
30
- body.write Zlib::Deflate.deflate(response_body)
31
- end
32
- end
33
- end
34
-
35
- class GzipHandler < BasicMongrelHandler
36
- def process(request, response)
37
- response.start do |head, body|
38
- head['Content-Encoding'] = 'gzip'
39
- body.write gzip(response_body)
40
- end
41
- end
42
-
43
- protected
44
-
45
- def gzip(string)
46
- sio = StringIO.new('', 'r+')
47
- gz = Zlib::GzipWriter.new sio
48
- gz.write string
49
- gz.finish
50
- sio.rewind
51
- sio.read
52
- end
53
- end
54
-
55
- module BasicAuthentication
56
- def self.extended(base)
57
- base.custom_headers["WWW-Authenticate"] = 'Basic Realm="Super Secret Page"'
58
- end
59
-
60
- def process(request, response)
61
- if authorized?(request)
62
- super
63
- else
64
- reply_with(response, 401, "Incorrect. You have 20 seconds to comply.")
65
- end
66
- end
67
-
68
- def authorized?(request)
69
- request.params["HTTP_AUTHORIZATION"] == "Basic " + Base64.encode64("#{@username}:#{@password}").strip
70
- end
71
- end
72
-
73
- module DigestAuthentication
74
- def self.extended(base)
75
- base.custom_headers["WWW-Authenticate"] = 'Digest realm="testrealm@host.com",qop="auth,auth-int",nonce="nonce",opaque="opaque"'
76
- end
77
-
78
- def process(request, response)
79
- if authorized?(request)
80
- super
81
- else
82
- reply_with(response, 401, "Incorrect. You have 20 seconds to comply.")
83
- end
84
- end
85
-
86
- def authorized?(request)
87
- request.params["HTTP_AUTHORIZATION"] =~ /Digest.*uri=/
88
- end
89
- end
90
-
91
- module DigestAuthenticationUsingMD5Sess
92
- NONCE = 'nonce'
93
- REALM = 'testrealm@host.com'
94
- QOP = 'auth,auth-int'
95
- def self.extended(base)
96
- base.custom_headers["WWW-Authenticate"] = %(Digest realm="#{REALM}",qop="#{QOP}",algorithm="MD5-sess",nonce="#{NONCE}",opaque="opaque"')
97
- end
98
-
99
- def process(request, response)
100
- if authorized?(request)
101
- super
102
- else
103
- reply_with(response, 401, "Incorrect. You have 20 seconds to comply.")
104
- end
105
- end
106
-
107
- def md5(str)
108
- Digest::MD5.hexdigest(str)
109
- end
110
-
111
- def authorized?(request)
112
- auth = request.params["HTTP_AUTHORIZATION"]
113
- params = {}
114
- auth.to_s.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }.gsub(/(\w+)=([^,]*)/) { params[$1] = $2 }
115
- a1a = [@username,REALM,@password].join(':')
116
- a1 = [md5(a1a),NONCE,params['cnonce'] ].join(':')
117
- a2 = [ request.params["REQUEST_METHOD"], request.params["REQUEST_URI"] ] .join(':')
118
- expected_response = md5( [md5(a1), NONCE, params['nc'], params['cnonce'], QOP, md5(a2)].join(':') )
119
- expected_response == params['response']
120
- end
121
- end
122
-
123
-
124
- def new_mongrel_redirector(target_url, relative_path = false)
125
- target_url = "http://#{@host_and_port}#{target_url}" unless relative_path
126
- Mongrel::RedirectHandler.new(target_url)
127
- end
@@ -1,92 +0,0 @@
1
- Given /a remote service that returns '(.*)'/ do |response_body|
2
- @handler = BasicMongrelHandler.new
3
- step "the response from the service has a body of '#{response_body}'"
4
- end
5
-
6
- Given /^a remote service that returns:$/ do |response_body|
7
- @handler = BasicMongrelHandler.new
8
- @handler.response_body = response_body
9
- end
10
-
11
- Given /a remote service that returns a (\d+) status code/ do |code|
12
- @handler = BasicMongrelHandler.new
13
- @handler.response_code = code
14
- end
15
-
16
- Given /that service is accessed at the path '(.*)'/ do |path|
17
- @server.register(path, @handler)
18
- end
19
-
20
- Given /^that service takes (\d+) (.*) to generate a response$/ do |time, unit|
21
- time = time.to_i
22
- time *= 60 if unit =~ /minute/
23
- @server_response_time = time
24
- @handler.preprocessor = proc { sleep time }
25
- end
26
-
27
- Given /^a remote deflate service$/ do
28
- @handler = DeflateHandler.new
29
- end
30
-
31
- Given /^a remote deflate service on port '(\d+)'/ do |port|
32
- run_server(port)
33
- @handler = DeflateHandler.new
34
- end
35
-
36
- Given /^a remote gzip service$/ do
37
- @handler = GzipHandler.new
38
- end
39
-
40
- Given /the response from the service has a Content-Type of '(.*)'/ do |content_type|
41
- @handler.content_type = content_type
42
- end
43
-
44
- Given /the response from the service has a body of '(.*)'/ do |response_body|
45
- @handler.response_body = response_body
46
- end
47
-
48
- Given /the url '(.*)' redirects to '(.*)'/ do |redirection_url, target_url|
49
- @server.register redirection_url, new_mongrel_redirector(target_url)
50
- end
51
-
52
- Given /that service is protected by Basic Authentication/ do
53
- @handler.extend BasicAuthentication
54
- end
55
-
56
- Given /that service is protected by Digest Authentication/ do
57
- @handler.extend DigestAuthentication
58
- end
59
-
60
- Given /that service is protected by MD5-sess Digest Authentication/ do
61
- @handler.extend DigestAuthenticationUsingMD5Sess
62
- end
63
-
64
- Given /that service requires the username '(.*)' with the password '(.*)'/ do |username, password|
65
- @handler.username = username
66
- @handler.password = password
67
- end
68
-
69
- # customize aruba cucumber step
70
- Then /^the output should contain '(.*)'$/ do |expected|
71
- expect(all_commands.map(&:output).join("\n")).to match_output_string(expected)
72
- end
73
-
74
- Given /a restricted page at '(.*)'/ do |url|
75
- steps "
76
- Given a remote service that returns 'A response I will never see'
77
- And that service is accessed at the path '#{url}'
78
- And that service is protected by Basic Authentication
79
- And that service requires the username 'something' with the password 'secret'
80
- "
81
- end
82
-
83
- # This joins the server thread, and halts cucumber, so you can actually hit the
84
- # server with a browser. Runs until you kill it with Ctrl-c
85
- Given /I want to hit this in a browser/ do
86
- @server.acceptor.join
87
- end
88
-
89
- Then /I wait for the server to recover/ do
90
- timeout = @request_options[:timeout] || 0
91
- sleep @server_response_time - timeout
92
- end
@@ -1,13 +0,0 @@
1
- Feature: Supports the read timeout option
2
- In order to handle inappropriately slow response times
3
- As a developer
4
- I want my request to raise an exception after my specified read_timeout as elapsed
5
-
6
- Scenario: A long running response
7
- Given a remote service that returns '<h1>Some HTML</h1>'
8
- And that service is accessed at the path '/long_running_service.html'
9
- And that service takes 2 seconds to generate a response
10
- When I set my HTTParty read_timeout option to 1
11
- And I call HTTParty#get with '/long_running_service.html'
12
- Then it should raise a Timeout::Error exception
13
- And I wait for the server to recover
@@ -1,22 +0,0 @@
1
- Feature: Supports Redirection
2
-
3
- As a developer
4
- I want to work with services that may redirect me
5
- And I want it to follow a reasonable number of redirects
6
- Because sometimes web services do that
7
-
8
- Scenario: A service that redirects once
9
- Given a remote service that returns 'Service Response'
10
- And that service is accessed at the path '/landing_service.html'
11
- And the url '/redirector.html' redirects to '/landing_service.html'
12
- When I call HTTParty#get with '/redirector.html'
13
- Then the return value should match 'Service Response'
14
-
15
- # TODO: Look in to why this actually fails...
16
- Scenario: A service that redirects to a relative URL
17
-
18
- Scenario: A service that redirects infinitely
19
- Given the url '/first.html' redirects to '/second.html'
20
- And the url '/second.html' redirects to '/first.html'
21
- When I call HTTParty#get with '/first.html'
22
- Then it should raise an HTTParty::RedirectionTooDeep exception
@@ -1,13 +0,0 @@
1
- Feature: Supports the timeout option
2
- In order to handle inappropriately slow response times
3
- As a developer
4
- I want my request to raise an exception after my specified timeout as elapsed
5
-
6
- Scenario: A long running response
7
- Given a remote service that returns '<h1>Some HTML</h1>'
8
- And that service is accessed at the path '/long_running_service.html'
9
- And that service takes 2 seconds to generate a response
10
- When I set my HTTParty timeout option to 1
11
- And I call HTTParty#get with '/long_running_service.html'
12
- Then it should raise a Timeout::Error exception
13
- And I wait for the server to recover
@@ -1,23 +0,0 @@
1
- <posts user="jnunemaker" tag="ruby">
2
- <post href="http://roxml.rubyforge.org/" hash="19bba2ab667be03a19f67fb67dc56917" description="ROXML - Ruby Object to XML Mapping Library" tag="ruby xml gems mapping" time="2008-08-09T05:24:20Z" others="56" extended="ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML. Using simple annotations, it enables Ruby classes to be custom-mapped to XML. ROXML takes care of the marshalling and unmarshalling of mapped attributes so that developers can focus on building first-class Ruby classes."/>
3
- <post href="http://code.google.com/p/sparrow/" hash="1df8a7cb9e8960992556518c0ea0d146" description="sparrow - Google Code" tag="ruby sparrow memcache queue" time="2008-08-06T15:07:24Z" others="115" extended="Sparrow is a really fast lightweight queue written in Ruby that speaks memcache. That means you can use Sparrow with any memcached client library (Ruby or otherwise)."/>
4
- <post href="http://code.google.com/p/query-reviewer/" hash="963187e8bf350ae42e21eee13a2bef07" description="query-reviewer - Google Code" tag="rails ruby railstips plugins database optimization" time="2008-08-04T21:50:14Z" others="180" extended="This rails plugin not only runs &quot;EXPLAIN&quot; before each of your select queries in development, but provides a small DIV in the rendered output of each page with the summary of query warnings that it analyzed."/>
5
- <post href="http://dev.zeraweb.com/introducing-functor" hash="2cdd545934bd37ae6f4829c51b3041c5" description="dev.zeraweb.com: Introducing Functor" tag="ruby methods gems railstips" time="2008-08-04T21:46:47Z" others="61" extended="Really cool ruby lib for overloading method definitions. I can think of a few places this would be handy."/>
6
- <post href="http://prawn.majesticseacreature.com/" hash="92764e019de7553b4cd38017e42e4aaa" description="prawn.majesticseacreature.com" tag="pdf ruby railstips" time="2008-08-04T21:26:20Z" others="237" extended="pure ruby pdf generation library."/>
7
- <post href="http://meme-rocket.com/2006/09/28/ruby-moduleinclude-at-odds-with-duck-typing/" hash="4ce96c7c237161819e9625737c22b462" description="Bill Burcham’s memeRocket :: Ruby Module#include at Odds with Duck Typing." tag="ruby railstips enumerable comparable" time="2008-08-03T16:09:24Z" others="3" extended="How to build your own enumerable and comparable objects in ruby. This article is old but just came across it and found it handy."/>
8
- <post href="http://bl.ogtastic.com/archives/2008/7" hash="6bebd138c037d7d7c88a7046ca03f671" description="The right way to do something you should never do" tag="juggernaut observers rails flash ruby" time="2008-08-03T03:50:58Z" others="0" extended="Example of how to use juggernaut with an observer."/>
9
- <post href="http://ncavig.com/blog/?page_id=8" hash="55450d103d6e2dd609b203ad133d751f" description="Nic’s Notions » Juggernaut Tutorials" tag="juggernaut rails ruby flash plugins server chat" time="2008-08-03T02:26:39Z" others="30" extended="Several juggernaut tutorials."/>
10
- <post href="http://blog.labnotes.org/2008/05/05/distributed-twitter-client-in-20-lines-of-code/" hash="7c2a36292db109b144036a02eb3f46b7" description="Labnotes » Distributed Twitter Client in 20 lines of code" tag="xmpp ruby jabber xmpp4r" time="2008-08-01T18:16:23Z" others="18" extended="Cool little snippet of xmpp goodness to check your buddies status messages."/>
11
- <post href="http://labs.reevoo.com/plugins/beanstalk-messaging" hash="d100c10208acbf5e954320a5577838d9" description="reevoolabs - Beanstalk Messaging" tag="railstips messaging queue rails ruby" time="2008-07-28T02:57:00Z" others="33" extended="Good write up on beanstalk"/>
12
- <post href="http://www.slideshare.net/guest807bb2/rubyfringe?src=embed" hash="c3dc3b940dbe25e39737240b4e1ab071" description="Rockstar Memcached" tag="memcached performance caching ruby rails railstips" time="2008-07-28T02:30:50Z" others="11" extended="Killer presentation on memcached by Tobi of Shopify."/>
13
- <post href="http://www.igvita.com/2008/07/22/unix-signals-for-live-debugging/" hash="288054a38d870b15bdf060ed5c6b2a2e" description="Unix Signals for Live Debugging - igvita.com" tag="ruby signals unix debugging signal railstips" time="2008-07-27T04:53:00Z" others="86" extended="I've known how to kill processes and such but never quite understood kill. Ilya Grigorik explains not only how to send those signals but how to use them in your scripts to change the way they behave on the fly. Very cool."/>
14
- <post href="http://www.rubyinside.com/redcloth-4-released-962.html" hash="b3db9b84940ce550e26a560b83eb2f66" description="RedCloth 4.0 Released: 40x Faster Textile Rendering" tag="textile ruby gems railstips" time="2008-07-27T04:42:29Z" others="20" extended="Redcloth gets some serious love. It's now much faster. Sweet!"/>
15
- <post href="http://code.google.com/p/rubycas-server/" hash="b532ea5933e4eba76c44823e17fecd31" description="rubycas-server - Google Code" tag="sso authentication cas ruby" time="2008-07-22T17:04:09Z" others="132" extended="RubyCAS-Server provides a single sign-on solution for web applications, implementing the server-end of JA-SIG's CAS protocol."/>
16
- <post href="http://reinh.com/blog/2008/07/14/a-thinking-mans-sphinx.html" hash="033d72ac54d8c722618383e0e2aa18ff" description="ReinH — A Thinking Man's Sphinx" tag="rails railstips sphinx search ruby" time="2008-07-17T19:34:59Z" others="142" extended="A guide to the two sphynx plugins: ultrasphynx and thinksphynx and why you should choose one or the other."/>
17
- <post href="http://www.rubyinside.com/ruby-xml-crisis-over-libxml-0-8-0-released-955.html" hash="70490d9786f09db5ba5f7904f88d304c" description="libxml-ruby 0.8.0 Released: Ruby Gets Fast, Reliable XML Processing At Last" tag="libxml xml ruby gems" time="2008-07-17T18:22:23Z" others="55" extended="lib xml gets an update and now it's really fast."/>
18
- <post href="http://github.com/RISCfuture/autumn/tree/master" hash="9b47db4bf59da2009642f4084e3113a2" description="autumn at master — GitHub" tag="irc ruby gems" time="2008-07-17T18:20:19Z" others="18" extended="Easy, fresh, feature-rich IRC bots in Ruby"/>
19
- <post href="http://groups.google.com/group/datamapper/browse_thread/thread/d33fbb20e41fad04" hash="4403898c92b37788f002ad6d79a66b68" description="New Finder Syntax (before 1.0) -" tag="railstips ruby datamapper" time="2008-07-05T20:42:27Z" others="1" extended="really cool idea for conditions in datamapper. even if you don't use datamapper, read this as it's sweet."/>
20
- <post href="http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html" hash="33bbf2492beac5fbf1fc167014060067" description="CodeClimber: using Ruby for IMAP with Gmail" tag="email gems gmail google imap rails railstips ruby" time="2008-07-05T20:06:47Z" others="118" extended="how to check gmail using ruby's IMAP libraries. the key is to use the login method instead of the authenticate one."/>
21
- <post href="http://xullicious.blogspot.com/2008/07/updated-curb-multi-interface-patch.html" hash="f95dcc012bdc13bc26bace3ceed10656" description="Xul for thought: Updated curb multi interface patch" tag="curl ruby http" time="2008-07-03T21:52:45Z" others="1" extended="Really cool multi curl stuff to rapidly hit urls."/>
22
- </posts>
23
- <!-- fe04.api.del.ac4.yahoo.net uncompressed/chunked Sat Aug 9 00:20:11 PDT 2008 -->
File without changes
@@ -1,3 +0,0 @@
1
- <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style>body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}#gbar{height:22px;padding-left:2px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.73em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}</style><script>window.google={kEI:"Zuk6ScOkLKHCMrrttckF",kEXPI:"17259,19124,19314",kHL:"en"};
2
- google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};function sf(){document.f.q.focus()}
3
- window.gbar={};(function(){var b=window.gbar,f,h;b.qs=function(a){var c=window.encodeURIComponent&&(document.forms[0].q||"").value;if(c)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(i,g){return(g||"&")+"q="+encodeURIComponent(c)})};function j(a,c){a.visibility=h?"hidden":"visible";a.left=c+"px"}b.tg=function(a){a=a||window.event;var c=0,i,g=window.navExtra,d=document.getElementById("gbi"),e=a.target||a.srcElement;a.cancelBubble=true;if(!f){f=document.createElement(Array.every||window.createPopup?"iframe":"div");f.frameBorder="0";f.src="#";d.parentNode.appendChild(f).id="gbs";if(g)for(i in g)d.insertBefore(g[i],d.firstChild).className="gb2";document.onclick=b.close}if(e.className!="gb3")e=e.parentNode;do c+=e.offsetLeft;while(e=e.offsetParent);j(d.style,c);f.style.width=d.offsetWidth+"px";f.style.height=d.offsetHeight+"px";j(f.style,c);h=!h};b.close=function(a){h&&b.tg(a)}})();</script></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="sf();if(document.images)new Image().src='/images/nav_logo3.png'" topmargin=3 marginheight=3><div id=gbar><nobr><b class=gb1>Web</b> <a href="http://images.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb1>Shopping</a> <a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" class=gb3><u>more</u> <small>&#9660;</small></a><div id=gbi> <a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb2>Video</a> <a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a> <a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://finance.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a> <a href="http://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=wo" class=gb2>Documents</a> <a href="http://www.google.com/reader/view/?hl=en&tab=wy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.google.com/intl/en/options/" class=gb2>even more &raquo;</a></div> </nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div align=right id=guser style="font-size:84%;padding:0 0 4px" width=100%><nobr><a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg">iGoogle</a> | <a href="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en">Sign in</a></nobr></div><center><br clear=all id=lgpd><img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276><br><br><form action="/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%>&nbsp;</td><td align=center nowrap><input name=hl type=hidden value=en><input type=hidden name=ie value="ISO-8859-1"><input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value=""><br><input name=btnG type=submit value="Google Search"><input name=btnI type=submit value="I'm Feeling Lucky"></td><td nowrap width=25%><font size=-2>&nbsp;&nbsp;<a href=/advanced_search?hl=en>Advanced Search</a><br>&nbsp;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><br><font size=-1><a href="/intl/en/ads/">Advertising&nbsp;Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>&copy;2008 - <a href="/intl/en/privacy.html">Privacy</a></font></p></center></body><script>if(google.y)google.y.first=[];window.setTimeout(function(){var xjs=document.createElement('script');xjs.src='/extern_js/f/CgJlbhICdXMgACswCjgMLCswDjgCLCswGDgDLA/8MIofMT_4o8.js';document.getElementsByTagName('head')[0].appendChild(xjs)},0);google.y.first.push(function(){google.ac.i(document.f,document.f.q,'','')})</script></html>
@@ -1,29 +0,0 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- if [ -d "generated" ] ; then
5
- echo >&2 "error: 'generated' directory already exists. Delete it first."
6
- exit 1
7
- fi
8
-
9
- mkdir generated
10
-
11
- # Generate the CA private key and certificate
12
- openssl req -batch -subj '/CN=INSECURE Test Certificate Authority' -newkey rsa:1024 -new -x509 -days 999999 -keyout generated/ca.key -nodes -out generated/ca.crt
13
-
14
- # Create symlinks for ssl_ca_path
15
- c_rehash generated
16
-
17
- # Generate the server private key and self-signed certificate
18
- openssl req -batch -subj '/CN=localhost' -newkey rsa:1024 -new -x509 -days 999999 -keyout generated/server.key -nodes -out generated/selfsigned.crt
19
-
20
- # Generate certificate signing request with bogus hostname
21
- openssl req -batch -subj '/CN=bogo' -new -days 999999 -key generated/server.key -nodes -out generated/bogushost.csr
22
-
23
- # Sign the certificate requests
24
- openssl x509 -CA generated/ca.crt -CAkey generated/ca.key -set_serial 1 -in generated/selfsigned.crt -out generated/server.crt -clrext -extfile openssl-exts.cnf -extensions cert -days 999999
25
- openssl x509 -req -CA generated/ca.crt -CAkey generated/ca.key -set_serial 1 -in generated/bogushost.csr -out generated/bogushost.crt -clrext -extfile openssl-exts.cnf -extensions cert -days 999999
26
-
27
- # Remove certificate signing requests
28
- rm -f generated/*.csr
29
-
@@ -1,16 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIICbTCCAdagAwIBAgIJAIAeO9TXtJ45MA0GCSqGSIb3DQEBBQUAMC4xLDAqBgNV
3
- BAMTI0lOU0VDVVJFIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MCAXDTEwMTAy
4
- MDEzNDYyM1oYDzQ3NDgwOTE1MTM0NjIzWjAuMSwwKgYDVQQDEyNJTlNFQ1VSRSBU
5
- ZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
6
- gYkCgYEA3lkBcd352qiIIzqnyvvJj59cx1dnzMyjnuaK2cRH420rBfukLE2MbOVr
7
- 9nYq/7CdjqXpE8uFAF+UTSIK6MWZ/bidkr2xd/et/Ce2pVIVxH+rt3pJz3wZhC3H
8
- Yz+HU4CD2iI9wAzsb6mMV7md1fjlYfir4SBGGPTkcqUJUp2/tQMCAwEAAaOBkDCB
9
- jTAdBgNVHQ4EFgQUy0Lz6RgmtpywlBOXdPABQArp358wXgYDVR0jBFcwVYAUy0Lz
10
- 6RgmtpywlBOXdPABQArp35+hMqQwMC4xLDAqBgNVBAMTI0lOU0VDVVJFIFRlc3Qg
11
- Q2VydGlmaWNhdGUgQXV0aG9yaXR5ggkAgB471Ne0njkwDAYDVR0TBAUwAwEB/zAN
12
- BgkqhkiG9w0BAQUFAAOBgQCmi3JQm+EIWjkRlyz9sijkYS+Ps4opmd/weeaXwa4E
13
- gVBWJGyiduB+kBnfv61+/tDjlrbjBDH5dP8suczHQL8gox4zGgjw64KH4o1ujZYR
14
- cEPbhnUpwbXu7yItlajBZfpFefjF5P0Ao2iEzQldDy0D6nQ19h5QANvQxqweTPQp
15
- pw==
16
- -----END CERTIFICATE-----