Skip to content

Commit

Permalink
Remove all deprecations (closes #208)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Nov 21, 2015
1 parent 011fcb1 commit b5b8c3c
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 74 deletions.
32 changes: 1 addition & 31 deletions lib/http/chainable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,12 @@ def follow(opts = {})
branch default_options.with_follow opts
end

# @deprecated will be removed in 1.0.0
# @see #follow
alias_method :with_follow, :follow

# Make a request with the given headers
# @param headers
def headers(headers)
branch default_options.with_headers(headers)
end

# @deprecated will be removed in 1.0.0
# @see #headers
alias_method :with, :headers

# @deprecated will be removed in 1.0.0
# @see #headers
alias_method :with_headers, :headers

# Make a request with the given cookies
def cookies(cookies)
branch default_options.with_cookies(cookies)
Expand All @@ -197,10 +185,7 @@ def accept(type)

# Make a request with the given Authorization header
# @param [#to_s] value Authorization header value
def auth(value, opts = nil)
# shim for deprecated auth(:basic, opts).
# will be removed in 0.8.0
return basic_auth(opts) if :basic == value
def auth(value)
headers Headers::AUTHORIZATION => value.to_s
end

Expand Down Expand Up @@ -229,21 +214,6 @@ def default_options=(opts)
@default_options = HTTP::Options.new(opts)
end

# @deprecated Will be removed in 1.0.0; Use `#default_options#headers`
# Get headers of HTTP options
def default_headers
default_options.headers
end

# Set headers of HTTP options
# @deprecated Will be removed in 1.0.0; Use `#headers`
# @param headers
def default_headers=(headers)
@default_options = default_options.dup do |opts|
opts.headers = headers
end
end

private

# :nodoc:
Expand Down
12 changes: 6 additions & 6 deletions lib/http/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class Connection
# @param [HTTP::Options] options
def initialize(req, options)
@persistent = options.persistent?
@keep_alive_timeout = options[:keep_alive_timeout].to_f
@keep_alive_timeout = options.keep_alive_timeout.to_f
@pending_request = false
@pending_response = false
@failed_proxy_connect = false

@parser = Response::Parser.new

@socket = options[:timeout_class].new(options[:timeout_options])
@socket.connect(options[:socket_class], req.socket_host, req.socket_port)
@socket = options.timeout_class.new(options.timeout_options)
@socket.connect(options.socket_class, req.socket_host, req.socket_port)

send_proxy_connect_request(req)
start_tls(req, options)
Expand Down Expand Up @@ -148,14 +148,14 @@ def expired?
def start_tls(req, options)
return unless req.uri.https? && !failed_proxy_connect?

ssl_context = options[:ssl_context]
ssl_context = options.ssl_context

unless ssl_context
ssl_context = OpenSSL::SSL::SSLContext.new
ssl_context.set_params(options[:ssl] || {})
ssl_context.set_params(Hash(options.ssl))
end

@socket.start_tls(req.uri.host, options[:ssl_socket_class], ssl_context)
@socket.start_tls(req.uri.host, options.ssl_socket_class, ssl_context)
end

# Open tunnel through proxy
Expand Down
3 changes: 0 additions & 3 deletions lib/http/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ def add(name, value)
Array(value).each { |v| @pile << [name, v.to_s] }
end

# @deprecated Will be removed in 1.0.0
alias_method :append, :add

# Returns list of header values if any.
#
# @return [Array<String>]
Expand Down
11 changes: 1 addition & 10 deletions lib/http/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@ def persistent?
!persistent.nil?
end

# @deprecated
def [](option)
send(option)
rescue
warn "[DEPRECATED] `HTTP::Options#[:#{option}]` was deprecated. " \
"Use `HTTP::Options##{option}` instead."
nil
end

def merge(other)
h1 = to_hash
h2 = other.to_hash
Expand All @@ -119,7 +110,7 @@ def merge(other)
def to_hash
hash_pairs = self.class.
defined_options.
flat_map { |opt_name| [opt_name, self[opt_name]] }
flat_map { |opt_name| [opt_name, send(opt_name)] }
Hash[*hash_pairs]
end

Expand Down
3 changes: 0 additions & 3 deletions lib/http/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ def headline
"#{verb.to_s.upcase} #{request_uri.omit :fragment} HTTP/#{version}"
end

# @deprecated Will be removed in 1.0.0
alias_method :request_header, :headline

# Compute HTTP request header SSL proxy connection
def proxy_connect_header
"CONNECT #{host}:#{port} HTTP/#{version}"
Expand Down
10 changes: 0 additions & 10 deletions lib/http/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ class Response

include HTTP::Headers::Mixin

# @deprecated Will be removed in 1.0.0
# Use Status::REASONS
STATUS_CODES = Status::REASONS

# @deprecated Will be removed in 1.0.0
SYMBOL_TO_STATUS_CODE = Hash[STATUS_CODES.map { |k, v| [v.downcase.gsub(/\s|-/, "_").to_sym, k] }].freeze

# @return [Status]
attr_reader :status

Expand All @@ -46,9 +39,6 @@ def initialize(status, version, headers, body, uri = nil) # rubocop:disable Para
# @return (see HTTP::Response::Status#code)
def_delegator :status, :code

# @deprecated Will be removed in 1.0.0
alias_method :status_code, :code

# @!method to_s
# (see HTTP::Response::Body#to_s)
def_delegator :body, :to_s
Expand Down
3 changes: 0 additions & 3 deletions lib/http/response/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ def to_sym
SYMBOLS[code]
end

# @deprecated Will be removed in 1.0.0
alias_method :symbolize, :to_sym

# Printable version of HTTP Status, surrounded by quote marks,
# with special characters escaped.
#
Expand Down
5 changes: 2 additions & 3 deletions spec/lib/http/options_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
RSpec.describe HTTP::Options do
subject { described_class.new(:response => :body) }

it "behaves like a Hash for reading" do
expect(subject[:response]).to eq(:body)
expect(subject[:nosuchone]).to be nil
it "has reader methods for attributes" do
expect(subject.response).to eq(:body)
end

it "coerces to a Hash" do
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/http/response/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
end
end

describe "#symbolize" do
subject { described_class.new(code).symbolize }
describe "#to_sym" do
subject { described_class.new(code).to_sym }

context "with unknown code" do
let(:code) { 1024 }
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@
describe ".auth" do
it "sets Authorization header to the given value" do
client = HTTP.auth "abc"
expect(client.default_headers[:authorization]).to eq "abc"
expect(client.default_options.headers[:authorization]).to eq "abc"
end

it "accepts any #to_s object" do
client = HTTP.auth double :to_s => "abc"
expect(client.default_headers[:authorization]).to eq "abc"
expect(client.default_options.headers[:authorization]).to eq "abc"
end
end

Expand All @@ -225,7 +225,7 @@

it "sets Authorization header with proper BasicAuth value" do
client = HTTP.basic_auth :user => "foo", :pass => "bar"
expect(client.default_headers[:authorization]).
expect(client.default_options.headers[:authorization]).
to match(%r{^Basic [A-Za-z0-9+/]+=*$})
end
end
Expand Down

0 comments on commit b5b8c3c

Please sign in to comment.