http 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1762fba28fba17df3f1257ea7b1fab8682e21d5348b41e9a22aba977f23061d
4
- data.tar.gz: af1584f93c3ee068274fadf006588f28bc258a797fa6ac03b506c49d43d10075
3
+ metadata.gz: ddb21214e710b5499c1d1074df10cb2467733d476996ff4b44ef476aad638d1a
4
+ data.tar.gz: a7e2ef9bb78b1b1b0bc2e06d8421d3d14bc4c4fe9ec5cedcafdcf1d4951978ee
5
5
  SHA512:
6
- metadata.gz: 34b2c514ffa2833bb2e276503f37dead1de43e987928031597f30bf431ac1293db2ec2f72aec6afbfc12e9ece16839db5e27536df8830a0d7abfff59b8727bfc
7
- data.tar.gz: cb5d5e41172fe3d9bf0619f1b359ff01246738c698a759f4e78e700b80c3174a0a223810ba03468a7c1300491630442698fd549e87f8a46b3bfc7f159acf9dac
6
+ metadata.gz: cba83eabbf6eed0eef8fcbd15da030a40d65c5ea8eceb1169cfdf2e114dbfb472762e673ddfd4552060b59b643d11bad4b70cbbda73dac9aceb05f15b772301c
7
+ data.tar.gz: c041c6ced64a2bdd994444975f3877d615be07245d91fb6825f4f8c9302b2c15aa1b98205b3401f6ebd77689d9831fb8982df15ba45478fd91703531328ea2f3
@@ -20,7 +20,8 @@ Metrics/AbcSize:
20
20
 
21
21
  Metrics/BlockLength:
22
22
  Exclude:
23
- - spec/**/*
23
+ - "spec/**/*"
24
+ - "**/*.gemspec"
24
25
 
25
26
  Metrics/BlockNesting:
26
27
  Max: 2
@@ -17,18 +17,19 @@ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
17
17
 
18
18
  rvm:
19
19
  # Include JRuby first because it takes the longest
20
- - jruby-9.1.16.0
20
+ - jruby-9.2.5.0
21
21
  - 2.3
22
22
  - 2.4
23
23
  - 2.5
24
+ - 2.6
24
25
 
25
26
  matrix:
26
27
  fast_finish: true
27
28
  include:
28
29
  # Only run RuboCop and Yardstick metrics on the latest Ruby
29
- - rvm: 2.5
30
+ - rvm: 2.6
30
31
  env: SUITE="rubocop"
31
- - rvm: 2.5
32
+ - rvm: 2.6
32
33
  env: SUITE="yardstick"
33
34
 
34
35
  branches:
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 4.2.0 (2019-10-22)
2
+
3
+ * Backport [#489](https://github.com/httprb/http/pull/489)
4
+ Fix HTTP parser.
5
+ ([@ixti], [@fxposter])
6
+
7
+
1
8
  ## 4.1.1 (2019-03-12)
2
9
 
3
10
  * Add `HTTP::Headers::ACCEPT_ENCODING` constant.
@@ -771,4 +778,5 @@ end
771
778
  [@tycoon]: https://github.com/tycooon
772
779
  [@paul]: https://github.com/paul
773
780
  [@RickCSong]: https://github.com/RickCSong
781
+ [@fxposter]: https://github.com/fxposter
774
782
  [@mamoonraja]: https://github.com/mamoonraja
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Build Status](https://secure.travis-ci.org/httprb/http.svg?branch=4-x-stable)](https://travis-ci.org/httprb/http)
5
5
  [![Code Climate](https://codeclimate.com/github/httprb/http.svg?branch=4-x-stable)](https://codeclimate.com/github/httprb/http)
6
6
  [![Coverage Status](https://coveralls.io/repos/httprb/http/badge.svg?branch=4-x-stable)](https://coveralls.io/r/httprb/http)
7
- [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/httprb/http/blob/master/LICENSE.txt)
7
+ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/httprb/http/blob/4-x-stable/LICENSE.txt)
8
8
 
9
9
  [Documentation]
10
10
 
@@ -167,7 +167,8 @@ versions:
167
167
  * Ruby 2.3.x
168
168
  * Ruby 2.4.x
169
169
  * Ruby 2.5.x
170
- * JRuby 9.1.x.x
170
+ * Ruby 2.6.x
171
+ * JRuby 9.2.x.x
171
172
 
172
173
  If something doesn't work on one of these versions, it's a bug.
173
174
 
@@ -197,5 +198,5 @@ dropped.
197
198
 
198
199
  ## Copyright
199
200
 
200
- Copyright (c) 2011-2018 Tony Arcieri, Alexey V. Zapparov, Erik Michaels-Ober, Zachary Anker.
201
+ Copyright (c) 2011-2019 Tony Arcieri, Alexey V. Zapparov, Erik Michaels-Ober, Zachary Anker.
201
202
  See LICENSE.txt for further details.
@@ -27,10 +27,10 @@ Gem::Specification.new do |gem|
27
27
 
28
28
  gem.required_ruby_version = ">= 2.3"
29
29
 
30
- gem.add_runtime_dependency "http_parser.rb", "~> 0.6.0"
31
- gem.add_runtime_dependency "http-form_data", "~> 2.0"
32
- gem.add_runtime_dependency "http-cookie", "~> 1.0"
33
30
  gem.add_runtime_dependency "addressable", "~> 2.3"
31
+ gem.add_runtime_dependency "http-cookie", "~> 1.0"
32
+ gem.add_runtime_dependency "http-form_data", "~> 2.0"
33
+ gem.add_runtime_dependency "http-parser", "~> 1.2.0"
34
34
 
35
35
  gem.add_development_dependency "bundler", "~> 2.0"
36
36
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "http/parser"
4
-
5
3
  require "http/errors"
6
4
  require "http/timeout/null"
7
5
  require "http/timeout/per_operation"
@@ -1,41 +1,66 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "http-parser"
4
+
3
5
  module HTTP
4
6
  class Response
7
+ # @api private
8
+ #
9
+ # NOTE(ixti): This class is a subject of future refactoring, thus don't
10
+ # expect this class API to be stable until this message disappears and
11
+ # class is not marked as private anymore.
5
12
  class Parser
6
13
  attr_reader :headers
7
14
 
8
15
  def initialize
9
- @parser = HTTP::Parser.new(self)
16
+ @state = HttpParser::Parser.new_instance { |i| i.type = :response }
17
+ @parser = HttpParser::Parser.new(self)
18
+
10
19
  reset
11
20
  end
12
21
 
22
+ # @return [self]
13
23
  def add(data)
14
- @parser << data
24
+ # XXX(ixti): API doc of HttpParser::Parser is misleading, it says that
25
+ # it returns boolean true if data was parsed successfully, but instead
26
+ # it's response tells if there was an error; So when it's `true` that
27
+ # means parse failed, and `false` means parse was successful.
28
+ # case of success.
29
+ return self unless @parser.parse(@state, data)
30
+
31
+ raise IOError, "Could not parse data"
15
32
  end
16
33
  alias << add
17
34
 
18
35
  def headers?
19
- !!@headers
36
+ @finished[:headers]
20
37
  end
21
38
 
22
39
  def http_version
23
- @parser.http_version.join(".")
40
+ @state.http_version
24
41
  end
25
42
 
26
43
  def status_code
27
- @parser.status_code
44
+ @state.http_status
28
45
  end
29
46
 
30
47
  #
31
48
  # HTTP::Parser callbacks
32
49
  #
33
50
 
34
- def on_headers_complete(headers)
35
- @headers = headers
51
+ def on_header_field(_response, field)
52
+ @field = field
53
+ end
54
+
55
+ def on_header_value(_response, value)
56
+ @headers.add(@field, value) if @field
57
+ end
58
+
59
+ def on_headers_complete(_reposse)
60
+ @finished[:headers] = true
36
61
  end
37
62
 
38
- def on_body(chunk)
63
+ def on_body(_response, chunk)
39
64
  if @chunk
40
65
  @chunk << chunk
41
66
  else
@@ -57,20 +82,21 @@ module HTTP
57
82
  chunk
58
83
  end
59
84
 
60
- def on_message_complete
61
- @finished = true
85
+ def on_message_complete(_response)
86
+ @finished[:message] = true
62
87
  end
63
88
 
64
89
  def reset
65
- @parser.reset!
90
+ @state.reset!
66
91
 
67
- @finished = false
68
- @headers = nil
92
+ @finished = Hash.new(false)
93
+ @headers = HTTP::Headers.new
94
+ @field = nil
69
95
  @chunk = nil
70
96
  end
71
97
 
72
98
  def finished?
73
- @finished
99
+ @finished[:message]
74
100
  end
75
101
  end
76
102
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTP
4
- VERSION = "4.1.1"
4
+ VERSION = "4.2.0"
5
5
  end
@@ -14,4 +14,11 @@ RSpec.describe "Regression testing" do
14
14
  expect { HTTP.get(google_uri).to_s }.not_to raise_error
15
15
  end
16
16
  end
17
+
18
+ describe "#422" do
19
+ it "reads body when 200 OK response contains Upgrade header" do
20
+ res = HTTP.get("https://httpbin.org/response-headers?Upgrade=h2,h2c")
21
+ expect(res.parse(:json)).to include("Upgrade" => "h2,h2c")
22
+ end
23
+ end
17
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -11,64 +11,64 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-03-12 00:00:00.000000000 Z
14
+ date: 2019-10-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: http_parser.rb
17
+ name: addressable
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: 0.6.0
22
+ version: '2.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 0.6.0
29
+ version: '2.3'
30
30
  - !ruby/object:Gem::Dependency
31
- name: http-form_data
31
+ name: http-cookie
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: '2.0'
36
+ version: '1.0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '2.0'
43
+ version: '1.0'
44
44
  - !ruby/object:Gem::Dependency
45
- name: http-cookie
45
+ name: http-form_data
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '1.0'
50
+ version: '2.0'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '1.0'
57
+ version: '2.0'
58
58
  - !ruby/object:Gem::Dependency
59
- name: addressable
59
+ name: http-parser
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '2.3'
64
+ version: 1.2.0
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: '2.3'
71
+ version: 1.2.0
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: bundler
74
74
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +186,7 @@ metadata:
186
186
  source_code_uri: https://github.com/httprb/http
187
187
  wiki_uri: https://github.com/httprb/http/wiki
188
188
  bug_tracker_uri: https://github.com/httprb/http/issues
189
- changelog_uri: https://github.com/httprb/http/blob/v4.1.1/CHANGES.md
189
+ changelog_uri: https://github.com/httprb/http/blob/v4.2.0/CHANGES.md
190
190
  post_install_message:
191
191
  rdoc_options: []
192
192
  require_paths: