http-parser-lite 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.4.0 (2012-06-30)
2
+
3
+ * added missing on_headers_complete callback.
4
+
1
5
  == 0.3.0 (2012-06-27)
2
6
 
3
7
  * Added optional type argument to Parser#initialize and Parser#reset
data/README.md CHANGED
@@ -21,6 +21,10 @@ parser.on_message_complete do
21
21
  puts "message complete"
22
22
  end
23
23
 
24
+ parser.on_headers_complete do
25
+ puts "value: #{value}"
26
+ end
27
+
24
28
  parser.on_url do |url|
25
29
  puts "url: #{url}"
26
30
  end
@@ -63,6 +67,7 @@ HTTP::Parser
63
67
  #on_url(&block)
64
68
  #on_header_field(&block)
65
69
  #on_header_value(&block)
70
+ #on_headers_complete(&block)
66
71
  #on_body(&block)
67
72
 
68
73
  #http_status
@@ -53,6 +53,12 @@ int rb_parser_on_header_value(http_parser *parser, char *data, size_t length) {
53
53
  return 0;
54
54
  }
55
55
 
56
+ int rb_parser_on_headers_complete(http_parser *parser) {
57
+ VALUE self = (VALUE)parser->data;
58
+ rb_parser_callback_call(self, "on_headers_complete", 0, 0);
59
+ return 0;
60
+ }
61
+
56
62
  int rb_parser_on_body(http_parser *parser, char *data, size_t length) {
57
63
  VALUE self = (VALUE)parser->data;
58
64
  rb_parser_callback_call(self, "on_body", data, length);
@@ -77,6 +83,7 @@ VALUE rb_parser_parse(VALUE self, VALUE data) {
77
83
  .on_url = (http_data_cb)rb_parser_on_url,
78
84
  .on_header_field = (http_data_cb)rb_parser_on_header_field,
79
85
  .on_header_value = (http_data_cb)rb_parser_on_header_value,
86
+ .on_headers_complete = (http_cb)rb_parser_on_headers_complete,
80
87
  .on_body = (http_data_cb)rb_parser_on_body,
81
88
  .on_message_begin = (http_cb)rb_parser_on_message_begin,
82
89
  .on_message_complete = (http_cb)rb_parser_on_message_complete
data/lib/http-parser.rb CHANGED
@@ -5,7 +5,7 @@ module HTTP
5
5
  TYPE_REQUEST = 0
6
6
  TYPE_RESPONSE = 1
7
7
  TYPE_BOTH = 2
8
- CALLBACKS = %w(on_url on_header_field on_header_value on_body on_message_begin on_message_complete)
8
+ CALLBACKS = %w(on_url on_header_field on_header_value on_headers_complete on_body on_message_begin on_message_complete)
9
9
 
10
10
  CALLBACKS.each do |name|
11
11
  define_method(name) do |&block|
@@ -40,10 +40,11 @@ describe 'http-parser' do
40
40
  parser.on_url {got << 'u'}
41
41
  parser.on_header_field {got << 'f'}
42
42
  parser.on_header_value {got << 'v'}
43
+ parser.on_headers_complete {got << 'h'}
43
44
  parser.on_body {got << 'b'}
44
45
 
45
46
  parser << "POST / HTTP/1.0\r\nContent-Type: text/plain\r\nContent-Length: 5\r\n\r\nhello"
46
- assert_equal %w(s u f v f v b e), got
47
+ assert_equal %w(s u f v f v h b e), got
47
48
  end
48
49
 
49
50
  it 'should parse chunked response' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-parser-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-27 00:00:00.000000000 Z
12
+ date: 2012-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake