Commit cd3c43f4 authored by Jonas Genannt's avatar Jonas Genannt

Imported Upstream version 0.9.1

parent c214c1f6
......@@ -2,4 +2,4 @@
--color
--format=documentation
--order random
--warnings
--require spec_helper
AllCops:
Include:
- 'Gemfile'
- 'Rakefile'
- 'http.gemspec'
# Avoid long parameter lists
ParameterLists:
Max: 3
CountKeywordArgs: true
Metrics/BlockNesting:
Max: 2
MethodLength:
Metrics/ClassLength:
CountComments: false
Max: 31 # TODO: lower to 15
Max: 125
Metrics/PerceivedComplexity:
Max: 8
Metrics/CyclomaticComplexity:
Max: 8 # TODO: Lower to 6
Metrics/LineLength:
AllowURI: true
Max: 143 # TODO: Lower to 80
ClassLength:
Metrics/MethodLength:
CountComments: false
Max: 100
Max: 22 # TODO: Lower to 15
CyclomaticComplexity:
Max: 13 # TODO: lower to 6
Metrics/ModuleLength:
CountComments: false
Max: 120
# Avoid more than `Max` levels of nesting.
BlockNesting:
Metrics/ParameterLists:
Max: 3
CountKeywordArgs: true
# Do not force public/protected/private keyword to be indented at the same
# level as the def keyword. My personal preference is to outdent these keywords
# because I think when scanning code it makes it easier to identify the
# sections of code and visually separate them. When the keyword is at the same
# level I think it sort of blends in with the def keywords and makes it harder
# to scan the code and see where the sections are.
AccessModifierIndentation:
Metrics/AbcSize:
Enabled: false
# Limit line length
LineLength:
Enabled: false
Style/CollectionMethods:
PreferredMethods:
collect: 'map'
reduce: 'inject'
find: 'detect'
find_all: 'select'
# Disable documentation checking until a class needs to be documented once
Documentation:
Style/Documentation:
Enabled: false
# Not all trivial readers/writers can be defined with attr_* methods
TrivialAccessors:
Enabled: false
Style/DotPosition:
EnforcedStyle: trailing
# Enforce Ruby 1.8-compatible hash syntax
HashSyntax:
EnforcedStyle: hash_rockets
# No spaces inside hash literals
SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space
Style/DoubleNegation:
Enabled: false
# Allow dots at the end of lines
DotPosition:
Style/EachWithObject:
Enabled: false
# Don't require magic comment at the top of every file
Encoding:
Style/Encoding:
Enabled: false
# Enforce outdenting of access modifiers (i.e. public, private, protected)
AccessModifierIndentation:
EnforcedStyle: outdent
Style/HashSyntax:
EnforcedStyle: hash_rockets
EmptyLinesAroundAccessModifier:
Enabled: true
Style/Lambda:
Enabled: false
# Align ends correctly
EndAlignment:
AlignWith: variable
Style/SingleSpaceBeforeFirstArg:
Enabled: false
# Indentation of when/else
CaseIndentation:
IndentWhenRelativeTo: end
IndentOneStep: false
Style/SpaceAroundOperators:
MultiSpaceAllowedForOperators:
- "="
- "=>"
- "||"
- "||="
- "&&"
- "&&="
# Use the old lambda literal syntax
Lambda:
Enabled: false
Style/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space
DoubleNegation:
Enabled: false
Style/StringLiterals:
EnforcedStyle: double_quotes
PercentLiteralDelimiters:
PreferredDelimiters:
'%': ()
'%i': ()
'%q': ()
'%Q': ()
'%r': '{}'
'%s': ()
'%w': '[]'
'%W': '[]'
'%x': ()
Semicolon:
Exclude:
- 'spec/support/'
# Do not force first argument to be separated with exactly single space.
# My (ixti) personal preference is to align code in columns when it makes
# sense:
#
# module HTTP
# module MimeType
# class JSON < Adapter
# register_adapter 'application/json', JSON
# register_alias 'application/json', :json
# end
# end
# end
SingleSpaceBeforeFirstArg:
Style/TrivialAccessors:
Enabled: false
bundler_args: --without development
bundler_args: --without development doc
env:
global:
- JRUBY_OPTS="$JRUBY_OPTS --debug"
language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1
- jruby-18mode
- jruby-19mode
- 2.2
- jruby
- jruby-head
- rbx-2
- ruby-head
- rbx-2
matrix:
allow_failures:
- rvm: jruby-head
- rvm: ruby-head
- rvm: rbx-2
fast_finish: true
sudo: false
--markup-provider=redcarpet
--markup=markdown
0.6.2 (2014-08-06)
------------------
## 0.9.1 (2015-08-14)
* Fix params special-chars escaping. See #246. (@ixti)
## 0.9.0 (2015-07-23)
* Support for caching removed. See #240. (@tarcieri)
* JRuby 9000 compatibility
## 0.8.12 (2015-05-26)
* Fix `HTTP.timeout` API (was loosing previously defined options). (@ixti)
## 0.8.11 (2015-05-22)
* SNI support for HTTPS connections. See #229. (@tarcieri)
* Use "http.rb" in the User-Agent string. See #227. (@tarcieri)
## 0.8.10 (2015-05-14)
* Fix cookie headers generation. (@ixti)
## 0.8.9 (2015-05-11)
* Add cookies support. (@ixti)
* Enforce stringified body encoding. See #219. (@Connorhd)
## 0.8.8 (2015-05-09)
* Fix CONNECT header for proxies. See #217. (@Connorhd)
## 0.8.7 (2015-05-08)
* Fix `HTTP.timeout` API with options only given. (@ixti)
## 0.8.6 (2015-05-08)
* Reset global timeouts after the request finishes. See #215. (@zanker)
## 0.8.5 (2015-05-06)
* Add simple timeouts configuration API. See #205. (@ixti)
* Deprecate `Request#request_header`. Use `Request#headline` instead. (@ixti)
## 0.8.4 (2015-04-23)
* Deprecate `#default_headers` and `#default_headers=`. (@ixti)
* Deprecate chainable methods with `with_` prefix. See #207. (@ixti)
* Add support of HTTPS connections through proxy. See #186. (@Connorhd)
## 0.8.3 (2015-04-07)
* Fix request headline. See #206. (@ixti)
* Remove deprecated `Request#__method__`. (@ixti)
## 0.8.2 (2015-04-06)
* Fix Celluloid::IO compatibility. See #203. (@ixti)
* Cleanup obsolete code. (@zanker)
## 0.8.1 (2015-04-02)
* Add missing `require "resolv"`. See #202. (@ixti)
* Add block-form `#persistent` calls. See #200, #201. (@ixti)
## 0.8.0 (2015-04-01)
* Properly handle WaitWritable for SSL. See #199. (@zanker)
* Add support for non-ASCII URis. See #197. (@ixti)
* Add configurable connection timeouts. See #187, #194, #195. (@zanker)
* Refactor requests redirect following logic. See #179. (@ixti)
* Support for persistent HTTP connections (@zanker)
* Add caching support. See #77 and #177. (@Asmod4n, @pezra)
* Improve servers used in specs boot up. Issue was initially raised up
by @olegkovalenko. See #176. (@ixti)
* Reflect FormData rename changes (FormData -> HTTP::FormData). (@ixti)
* `HTTP::Headers` now raises `HTTP::InvalidHeaderNameError` in case of
(surprise) invalid HTTP header field name (e.g.`"Foo:Bar"`). See #173.
(@ixti)
## 0.7.3 (2015-03-24)
* SECURITY FIX: http.rb failed to call the `#post_connection_check` method on
SSL connections. This method implements hostname verification, and without it
`http.rb` was vulnerable to MitM attacks. The problem was corrected by calling
`#post_connection_check` (CVE-2015-1828) (@zanker)
## 0.7.2 (2015-03-02)
* Swap from `form_data` to `http-form_data` (changed gem name).
## 0.7.1 (2015-01-03)
* Gemspec fixups
* Remove superfluous space in HTTP::Response inspection
## 0.7.0 (2015-01-02)
* Add support of multipart form data. See #73, #167. (@ixti)
* Fix URI path normalization: `https://github.com` -> `https://github.com/`.
(@ixti)
* Fix handling of EOF which caused infinite loop. See #163, #166 and #152. (@mickm, @ixti)
* Drop Ruby 1.8.7 support. (@ixti)
* Fix default Host header value. See #150. (@ixti)
* Remove BearerToken authorization header. (@ixti)
* `#auth` sugar now accepts only string value of Authorization header.
Calling `#auth(:basic, opts)` is deprecated, use `#basic_auth(opts)` instead.
(@ixti)
* Fix handling of chunked responses without Content-Length header. (@ixti)
* Remove `HTTP::Request#method` and deprecate `HTTP::Request#__method__`
(@sferik)
* Deprecate `HTTP::Response::STATUS_CODES`,
use `HTTP::Response::Status::REASONS` instead (@ixti)
* Deprecate `HTTP::Response::SYMBOL_TO_STATUS_CODE` (@ixti)
* Deprecate `HTTP::Response#status_code` (@ixti)
* `HTTP::Response#status` now returns `HTTP::Response::Status`. (@ixti)
* `HTTP::Response#reason` and `HTTP::Response#code` are proxies them
to corresponding methods of `HTTP::Response#status` (@ixti)
* Rename `HTTP.with_follow` to `HTTP.follow` and mark former one as being
deprecated (@ixti)
* Delegate `HTTP::Response#readpartial` to `HTTP::Response::Body` (@ixti)
## 0.6.4 (2015-03-25)
* SECURITY FIX: http.rb failed to call the `#post_connection_check` method on
SSL connections. This method implements hostname verification, and without it
`http.rb` was vulnerable to MitM attacks. The problem was corrected by calling
`#post_connection_check` (CVE-2015-1828) (@zanker, backported by @nicoolas25)
## 0.6.3 (2014-11-14)
* Backported EOF fix from master branch. See #166. (@ixti)
## 0.6.2 (2014-08-06)
* Fix default Host header value. See #150. (@ixti)
* Deprecate BearerToken authorization header. (@ixti)
......@@ -7,8 +160,8 @@
* Rename `HTTP.with_follow` to `HTTP.follow` and mark former one as being
deprecated (@ixti)
0.6.1 (2014-05-07)
------------------
## 0.6.1 (2014-05-07)
* Fix request `Content-Length` calculation for Unicode (@challengeechallengee)
* Add `Response#flush` (@ixti)
......@@ -17,8 +170,8 @@
* Fix forgotten CGI require (@ixti)
* Improve README (@tarcieri)
0.6.0 (2014-04-04)
------------------
## 0.6.0 (2014-04-04)
* Rename `HTTP::Request#method` to `HTTP::Request#verb` (@krainboltgreene)
* Add `HTTP::ResponseBody` class (@tarcieri)
......@@ -80,16 +233,17 @@ File.open "/tmp/dummy.bin", "wb" do |io|
end
```
[Changes discussion](https://github.com/tarcieri/http/issues/116)
[Changes discussion](https://github.com/httprb/http.rb/issues/116)
0.5.1 (2014-05-27)
------------------
## 0.5.1 (2014-05-27)
* Backports redirector fixes from 0.6.0 (@ixti)
* EOL of 0.5.X branch.
0.5.0
-----
## 0.5.0 (2013-09-14)
* Add query string support
* New response delegator allows HTTP.get(uri).response
* HTTP::Chainable#stream provides a shorter alias for
......@@ -97,36 +251,42 @@ end
* Better string inspect for HTTP::Response
* Curb compatibility layer removed
0.4.0
-----
## 0.4.0 (2012-10-12)
* Fix bug accessing https URLs
* Fix several instances of broken redirect handling
* Add default user agent
* Many additional minor bugfixes
0.3.0
-----
## 0.3.0 (2012-09-01)
* New implementation based on tmm1's http_parser.rb instead of Net::HTTP
* Support for following redirects
* Support for request body through {:body => ...} option
* HTTP#with_response (through Chainable)
0.2.0
-----
## 0.2.0 (2012-03-05)
* Request and response objects
* Callback system
* Internal refactoring ensuring true chainability
* Use the certified gem to ensure SSL certificate verification
0.1.0
-----
## 0.1.0 (2012-01-26)
* Testing against WEBrick
* Curb compatibility (require 'http/compat/curb')
0.0.1
-----
## 0.0.1 (2011-10-11)
* Initial half-baked release
0.0.0
-----
## 0.0.0 (2011-10-06)
* Vapoware release to claim the "http" gem name >:D
# Help and Discussion
If you need help or just want to talk about the http.rb,
visit the http.rb Google Group:
https://groups.google.com/forum/#!forum/httprb
You can join by email by sending a message to:
[httprb+subscribe@googlegroups.com](mailto:httprb+subscribe@googlegroups.com)
# Reporting bugs
The best way to report a bug is by providing a reproduction script. A half
working script with comments for the parts you were unable to automate is still
appreciated.
In any case, specify following info in description of your issue:
- What you're trying to accomplish
- What you expected to happen
- What actually happened
- The exception backtrace(s), if any
- Version of gem or commit ref you are using
source 'http://rubygems.org'
source "https://rubygems.org"
gem 'rake', '~> 10.1.1'
gem 'jruby-openssl' if defined? JRUBY_VERSION
gem "rake"
gem "rack-cache", "~> 1.2"
group :development do
gem 'pry'
gem "celluloid-io"
gem "guard"
gem "guard-rspec", :require => false
gem "nokogiri", :require => false
gem "pry"
platforms :ruby_19, :ruby_20 do
gem 'pry-debugger'
gem 'pry-stack_explorer'
end
platforms :ruby_19, :ruby_20, :ruby_21 do
gem 'celluloid-io'
gem 'guard-rspec'
gem "pry-debugger"
gem "pry-stack_explorer"
end
end
group :test do
gem 'backports'
gem 'coveralls'
gem 'json', '>= 1.8.1', :platforms => [:jruby, :rbx, :ruby_18, :ruby_19]
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
gem 'rspec', '~> 2.14'
gem 'rubocop', '~> 0.24.0', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'simplecov', '>= 0.9'
gem 'yardstick'
gem "backports"
gem "coveralls"
gem "simplecov", ">= 0.9"
gem "json", ">= 1.8.1"
gem "rspec", "~> 3.0"
gem "rspec-its"
gem "rubocop"
gem "yardstick"
gem "certificate_authority"
end
group :doc do
gem "kramdown"
gem "yard"
end
# Specify your gem's dependencies in http.gemspec
......
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end
guard :rspec, :cmd => "GUARD_RSPEC=1 bundle exec rspec --no-profile" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)
# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)
end
Copyright (c) 2014 Tony Arcieri, Erik Michaels-Ober
Copyright (c) 2011-2015 Tony Arcieri, Erik Michaels-Ober, Alexey V. Zapparov, Zachary Anker
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
......
This diff is collapsed.
#!/usr/bin/env rake
require 'bundler/gem_tasks'
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new
task :test => :spec
begin
require 'rubocop/rake_task'
require "rubocop/rake_task"
RuboCop::RakeTask.new
rescue LoadError
task :rubocop do
$stderr.puts 'RuboCop is disabled'
$stderr.puts "RuboCop is disabled"
end
end
require 'yardstick/rake/measurement'
require "yardstick/rake/measurement"
Yardstick::Rake::Measurement.new do |measurement|
measurement.output = 'measurement/report.txt'
measurement.output = "measurement/report.txt"
end
require 'yardstick/rake/verify'
require "yardstick/rake/verify"
Yardstick::Rake::Verify.new do |verify|
verify.require_exact_threshold = false
verify.threshold = 58
end
task :generate_status_codes do
require "http"
require "nokogiri"
url = "http://www.iana.org/assignments/http-status-codes/http-status-codes.xml"
xml = Nokogiri::XML HTTP.get url
arr = xml.xpath("//xmlns:record").reduce [] do |a, e|
code = e.xpath("xmlns:value").text.to_s
desc = e.xpath("xmlns:description").text.to_s
next a if "Unassigned" == desc || "(Unused)" == desc
a << "#{code} => #{desc.inspect}"
end
File.open("./lib/http/response/status/reasons.rb", "w") do |io|
io.puts <<-TPL.gsub(/^[ ]{6}/, "")
# AUTO-GENERATED FILE, DO NOT CHANGE IT MANUALLY
require "delegate"
module HTTP
class Response
class Status < ::Delegator
# Code to Reason map
#
# @example Usage
#
# REASONS[400] # => "Bad Request"
# REASONS[414] # => "Request-URI Too Long"
#
# @return [Hash<Fixnum => String>]
REASONS = {
#{arr.join ",\n "}
}.each { |_, v| v.freeze }.freeze
end
end
end
TPL
end
end
task :default => [:spec, :rubocop, :verify_measurements]
......@@ -6,8 +6,8 @@
# Run as: bundle exec examples/parallel_requests_with_celluloid.rb
#
require 'celluloid/io'
require 'http'
require "celluloid/io"
require "http"
class HttpFetcher
include Celluloid::IO
......@@ -21,7 +21,7 @@ end
fetcher = HttpFetcher.new
urls = %w[http://ruby-lang.org/ http://rubygems.org/ http://celluloid.io/]
urls = %w(http://ruby-lang.org/ http://rubygems.org/ http://celluloid.io/)
# Kick off a bunch of future calls to HttpFetcher to grab the URLs in parallel
futures = urls.map { |u| [u, fetcher.future.fetch(u)] }
......
lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'http/version'
require "http/version"
Gem::Specification.new do |gem|
gem.authors = %w[Tony Arcieri]
gem.email = %w[tony.arcieri@gmail.com]
gem.authors = ["Tony Arcieri", "Erik Michaels-Ober", "Alexey V. Zapparov", "Zachary Anker"]
gem.email = ["bascule@gmail.com"]
gem.description = <<-DESCRIPTION.strip.gsub(/\s+/, ' ')
gem.description = <<-DESCRIPTION.strip.gsub(/\s+/, " ")
An easy-to-use client library for making requests from Ruby.
It uses a simple method chaining system for building requests,
similar to Python's Requests.
DESCRIPTION
gem.summary = 'HTTP should be easy'
gem.homepage = 'https://github.com/tarcieri/http'
gem.licenses = %w[MIT]
gem.summary = "HTTP should be easy"
gem.homepage = "https://github.com/httprb/http.rb"
gem.licenses = ["MIT"]
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = 'http'
gem.require_paths = %w[lib]
gem.name = "http"
gem.require_paths = ["lib"]
gem.version = HTTP::VERSION
gem.add_runtime_dependency 'http_parser.rb', '~> 0.6.0'
gem.add_runtime_dependency "http_parser.rb", "~> 0.6.0"
gem.add_runtime_dependency "http-form_data", "~> 1.0.1"
gem.add_runtime_dependency "http-cookie", "~> 1.0"
gem.add_runtime_dependency "addressable", "~> 2.3"
gem.add_development_dependency 'bundler', '~> 1.0'
gem.add_development_dependency "bundler", "~> 1.0"
end
require 'http/parser'
require "http/parser"
require 'http/errors'
require 'http/chainable'
require 'http/client'
require 'http/options'