pico_http_parser 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ MAX_HEADER_LEN = 1024;
4
+ MAX_HEADERS = 128;
5
+ crlf = "\015\012";
6
+
7
+ describe PicoHTTPParser do
8
+
9
+ it 'very long name' do
10
+ env = {}
11
+ name = 'x' * MAX_HEADER_LEN; # OK
12
+ request = "GET / HTTP/1.1" + crlf + name + ": 42" + crlf + crlf;
13
+ ret = PicoHTTPParser.parse_http_request(request,env)
14
+ expect(ret).to be > 0;
15
+ expect(env["REQUEST_METHOD"]).to match("GET")
16
+ expect(env["HTTP_"+name.upcase]).to match("42")
17
+ end
18
+
19
+
20
+ it 'very long name fail' do
21
+ env = {}
22
+ name = 'x' * (MAX_HEADER_LEN+2); # OK
23
+ request = "GET / HTTP/1.1" + crlf + name + ": 42" + crlf + crlf;
24
+ ret = PicoHTTPParser.parse_http_request(request,env)
25
+ expect(ret).to be == -1;
26
+ expect(env["REQUEST_METHOD"]).to be nil
27
+ expect(env["HTTP_"+name.upcase]).to be nil
28
+ end
29
+
30
+ it 'too may headers fail' do
31
+ env = {}
32
+ request = "GET / HTTP/1.1" + crlf +
33
+ (0..MAX_HEADERS).map{|i| "X"+i.to_s+": "+i.to_s}.join(crlf) +
34
+ crlf + crlf
35
+ ret = PicoHTTPParser.parse_http_request(request,env)
36
+ expect(ret).to be == -1;
37
+ end
38
+
39
+
40
+ it 'too may headers ok' do
41
+ env = {}
42
+ request = "GET / HTTP/1.1" + crlf +
43
+ (1..MAX_HEADERS).map{|i| "X"+i.to_s+": "+i.to_s}.join(crlf) +
44
+ crlf + crlf
45
+ ret = PicoHTTPParser.parse_http_request(request,env)
46
+ expect(ret).to eq(request.length);
47
+ end
48
+
49
+
50
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'pico_http_parser'
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pico_http_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Masahiro Nagano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ description: Fast HTTP parser using picohttparser
56
+ email:
57
+ - kazeburo@gmail.com
58
+ executables: []
59
+ extensions:
60
+ - ext/pico_http_parser/extconf.rb
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".gitmodules"
65
+ - ".rspec"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - benchmark/bench_helper.rb
71
+ - benchmark/benchmark.pl
72
+ - ext/pico_http_parser/extconf.rb
73
+ - ext/pico_http_parser/pico_http_parser.c
74
+ - ext/pico_http_parser/picohttpparser/.gitattributes
75
+ - ext/pico_http_parser/picohttpparser/.gitmodules
76
+ - ext/pico_http_parser/picohttpparser/.travis.yml
77
+ - ext/pico_http_parser/picohttpparser/Makefile
78
+ - ext/pico_http_parser/picohttpparser/README.md
79
+ - ext/pico_http_parser/picohttpparser/bench.c
80
+ - ext/pico_http_parser/picohttpparser/picohttpparser.c
81
+ - ext/pico_http_parser/picohttpparser/picohttpparser.h
82
+ - ext/pico_http_parser/picohttpparser/test.c
83
+ - lib/pico_http_parser.rb
84
+ - lib/pico_http_parser/version.rb
85
+ - pico_http_parser.gemspec
86
+ - spec/01_simple_spec.rb
87
+ - spec/02_too_much_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://github.com/kazeburo/pico_http_parser
90
+ licenses:
91
+ - Artistic
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Fast HTTP parser using picohttparser
113
+ test_files:
114
+ - spec/01_simple_spec.rb
115
+ - spec/02_too_much_spec.rb
116
+ - spec/spec_helper.rb