http-parser 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ef7dd40436524e48ef90904d871caed3ba2754d6
4
- data.tar.gz: d1eebb668464073456f155757c4d34d06c3ebd1d
5
- SHA512:
6
- metadata.gz: 477ec97207cb8c602db5279f4e1ef315cb896d3d79e2669c712d0c4a950c36b941a8d1aa5ba490813e6bd5a6befcbd5947f00dd1d1e28acaeb340d20c789f111
7
- data.tar.gz: e5b18b9ddd5bc2befbd6b334834bc9cd16f5428c2d0413bb791a0ede0141ca9f6dbed49daddc42177dcf96b5e51610fcdc92bc5ea5753b66f15e2cccb5d31cbf
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjlmZDQwNmJmYjJlNWMzY2NmZmFlZDcwNWQ2NDUwZjQ0OWIzNzljNw==
5
+ data.tar.gz: !binary |-
6
+ YjhiMTgxOTMxNGViODRmYjM0YTE5MmU1YTNmMmViZGM4ZjM1ZDhkMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODNiNzNmM2Q3ZjE4Mjk1NzFiMDQ5ZDM3YTUxNGM5OGVlNWI3MWMzMzQ5NjIx
10
+ NGQ0YTYyYzYyNDZhOTE4NTZkMGYxZjY3ZjllMzViZGY0Nzk3NDM0NmFjYTll
11
+ YzI3NjFiOGJiNjI0MmFmZDc4NjJkOTI0YmFlNjkwMmM5NDVmYmU=
12
+ data.tar.gz: !binary |-
13
+ Nzc3MTM3ZTc2ZTJjMzYxZThmY2IzMTJlMWQzZGU4MjIyZDNkODMyN2RmNWE2
14
+ OTNkYzYzMTM1MjM1MjMyOTUxZDkzY2VjMzk4YzU4NTZmMTQ2ODQwOWZkMWVj
15
+ ZmIyM2Q4MzkwN2Y4NmY5OTJkZGIyNTI0MTUyZWZkYzQ5ZDQxMWQ=
@@ -14,6 +14,7 @@ module HttpParser
14
14
  #
15
15
  def initialize
16
16
  @settings = ::HttpParser::Settings.new
17
+ @callbacks = {} # so GC doesn't clean them up on java
17
18
  yield self if block_given?
18
19
  end
19
20
 
@@ -27,7 +28,9 @@ module HttpParser
27
28
  # The state so far of the request / response being processed.
28
29
  #
29
30
  def on_message_begin(&block)
30
- @settings[:on_message_begin] = Callback.new(&block)
31
+ cb = Callback.new(&block)
32
+ @callbacks[:on_message_begin] = cb
33
+ @settings[:on_message_begin] = cb
31
34
  end
32
35
 
33
36
  #
@@ -46,7 +49,9 @@ module HttpParser
46
49
  # @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
47
50
  #
48
51
  def on_url(&block)
49
- @settings[:on_url] = DataCallback.new(&block)
52
+ cb = DataCallback.new(&block)
53
+ @callbacks[:on_url] = cb
54
+ @settings[:on_url] = cb
50
55
  end
51
56
 
52
57
  #
@@ -59,7 +64,9 @@ module HttpParser
59
64
  # The state so far of the request / response being processed.
60
65
  #
61
66
  def on_status_complete(&block)
62
- @settings[:on_status_complete] = Callback.new(&block)
67
+ cb = Callback.new(&block)
68
+ @callbacks[:on_status_complete] = cb
69
+ @settings[:on_status_complete] = cb
63
70
  end
64
71
 
65
72
  #
@@ -78,7 +85,9 @@ module HttpParser
78
85
  # @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
79
86
  #
80
87
  def on_header_field(&block)
81
- @settings[:on_header_field] = DataCallback.new(&block)
88
+ cb = DataCallback.new(&block)
89
+ @callbacks[:on_header_field] = cb
90
+ @settings[:on_header_field] = cb
82
91
  end
83
92
 
84
93
  #
@@ -97,7 +106,9 @@ module HttpParser
97
106
  # @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
98
107
  #
99
108
  def on_header_value(&block)
100
- @settings[:on_header_value] = DataCallback.new(&block)
109
+ cb = DataCallback.new(&block)
110
+ @callbacks[:on_header_value] = cb
111
+ @settings[:on_header_value] = cb
101
112
  end
102
113
 
103
114
  #
@@ -110,7 +121,9 @@ module HttpParser
110
121
  # The state so far of the request / response being processed.
111
122
  #
112
123
  def on_headers_complete(&block)
113
- @settings[:on_headers_complete] = Callback.new(&block)
124
+ cb = Callback.new(&block)
125
+ @callbacks[:on_headers_complete] = cb
126
+ @settings[:on_headers_complete] = cb
114
127
  end
115
128
 
116
129
  #
@@ -130,7 +143,9 @@ module HttpParser
130
143
  # @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
131
144
  #
132
145
  def on_body(&block)
133
- @settings[:on_body] = DataCallback.new(&block)
146
+ cb = DataCallback.new(&block)
147
+ @callbacks[:on_body] = cb
148
+ @settings[:on_body] = cb
134
149
  end
135
150
 
136
151
  #
@@ -143,7 +158,9 @@ module HttpParser
143
158
  # The state so far of the request / response being processed.
144
159
  #
145
160
  def on_message_complete(&block)
146
- @settings[:on_message_complete] = Callback.new(&block)
161
+ cb = Callback.new(&block)
162
+ @callbacks[:on_message_complete] = cb
163
+ @settings[:on_message_complete] = cb
147
164
  end
148
165
 
149
166
  #
@@ -167,12 +184,12 @@ module HttpParser
167
184
  protected
168
185
 
169
186
 
170
- class Callback < Proc
187
+ class Callback < ::FFI::Function
171
188
  #
172
189
  # Creates a new Parser callback.
173
190
  #
174
191
  def self.new(&block)
175
- super do |parser|
192
+ super(:int, [::HttpParser::Instance.ptr]) do |parser|
176
193
  begin
177
194
  catch(:return) { yield(parser); 0 }
178
195
  rescue
@@ -182,9 +199,9 @@ module HttpParser
182
199
  end
183
200
  end
184
201
 
185
- class DataCallback < Proc
202
+ class DataCallback < ::FFI::Function
186
203
  def self.new(&block)
187
- super do |parser, buffer, length|
204
+ super(:int, [::HttpParser::Instance.ptr, :pointer, :size_t]) do |parser, buffer, length|
188
205
  begin
189
206
  data = buffer.get_bytes(0, length)
190
207
  catch(:return) { yield(parser, data); 0 }
@@ -113,7 +113,6 @@ module HttpParser
113
113
  def reset!(new_type = type)
114
114
  ::HttpParser.http_parser_init(self, new_type)
115
115
  end
116
- alias reset reset!
117
116
 
118
117
  #
119
118
  # The type of the parser.
@@ -1,3 +1,3 @@
1
1
  module HttpParser
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,74 +1,79 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-29 00:00:00.000000000 Z
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi-compiler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.0.2
20
- type: :runtime
21
- prerelease: false
22
20
  version_requirements: !ruby/object:Gem::Requirement
23
21
  requirements:
24
- - - '>='
22
+ - - ! '>='
25
23
  - !ruby/object:Gem::Version
26
24
  version: 0.0.2
25
+ type: :runtime
26
+ prerelease: false
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
33
+ version: !binary |-
34
+ MA==
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - '>='
37
+ - - ! '>='
39
38
  - !ruby/object:Gem::Version
40
- version: '0'
39
+ version: !binary |-
40
+ MA==
41
+ type: :runtime
42
+ prerelease: false
41
43
  - !ruby/object:Gem::Dependency
42
44
  name: rspec
43
45
  requirement: !ruby/object:Gem::Requirement
44
46
  requirements:
45
- - - '>='
47
+ - - ! '>='
46
48
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
49
+ version: !binary |-
50
+ MA==
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - '>='
53
+ - - ! '>='
53
54
  - !ruby/object:Gem::Version
54
- version: '0'
55
+ version: !binary |-
56
+ MA==
57
+ type: :development
58
+ prerelease: false
55
59
  - !ruby/object:Gem::Dependency
56
60
  name: yard
57
61
  requirement: !ruby/object:Gem::Requirement
58
62
  requirements:
59
- - - '>='
63
+ - - ! '>='
60
64
  - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
65
+ version: !binary |-
66
+ MA==
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - '>='
69
+ - - ! '>='
67
70
  - !ruby/object:Gem::Version
68
- version: '0'
69
- description: |2
70
- A super fast http parser for ruby.
71
- Cross platform and multiple ruby implementation support thanks to ffi.
71
+ version: !binary |-
72
+ MA==
73
+ type: :development
74
+ prerelease: false
75
+ description: ! " A super fast http parser for ruby.\n Cross platform and multiple
76
+ ruby implementation support thanks to ffi.\n"
72
77
  email:
73
78
  - steve@cotag.me
74
79
  executables: []
@@ -77,12 +82,12 @@ extensions:
77
82
  extra_rdoc_files:
78
83
  - README.md
79
84
  files:
85
+ - lib/http-parser.rb
80
86
  - lib/http-parser/errors.rb
81
87
  - lib/http-parser/ext.rb
82
88
  - lib/http-parser/parser.rb
83
89
  - lib/http-parser/types.rb
84
90
  - lib/http-parser/version.rb
85
- - lib/http-parser.rb
86
91
  - Rakefile
87
92
  - http-parser.gemspec
88
93
  - README.md
@@ -103,14 +108,16 @@ require_paths:
103
108
  - lib
104
109
  required_ruby_version: !ruby/object:Gem::Requirement
105
110
  requirements:
106
- - - '>='
111
+ - - ! '>='
107
112
  - !ruby/object:Gem::Version
108
- version: '0'
113
+ version: !binary |-
114
+ MA==
109
115
  required_rubygems_version: !ruby/object:Gem::Requirement
110
116
  requirements:
111
- - - '>='
117
+ - - ! '>='
112
118
  - !ruby/object:Gem::Version
113
- version: '0'
119
+ version: !binary |-
120
+ MA==
114
121
  requirements: []
115
122
  rubyforge_project:
116
123
  rubygems_version: 2.0.6