eventmachine-eventmachine_httpserver 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,48 @@
1
+ = eventmachine_httpserver
2
+
3
+ == EM::HttpServer vs Thin
4
+
5
+ +careo | is there a 25 word version of how it differs from thin?
6
+ +tmm1 | good question.. its probably faster, but only because it doesn't have a real http parser like thin
7
+ +wyhaines | It is faster. It's more of an nginx style parser than the mongrel, grammar based parser.
8
+ +careo | so perhaps a better fit for putting an http interface on top of a bunch of already-evented code?
9
+ +wyhaines | careo: It depends. There are very valid arguments for using an RFC-compliant parser a lot of the time.
10
+ +wyhaines | But, yeah, sometimes being strictly RFC compliant isn't something that you care about.
11
+
12
+ == Usage example
13
+
14
+ require 'eventmachine'
15
+ require 'evma_httpserver'
16
+
17
+ class MyHttpServer < EM::Connection
18
+ include EM::HttpServer
19
+
20
+ def post_init
21
+ super
22
+ no_environment_strings
23
+ end
24
+
25
+ def process_http_request
26
+ # the http request details are available via the following instance variables:
27
+ # @http_protocol
28
+ # @http_request_method
29
+ # @http_cookie
30
+ # @http_if_none_match
31
+ # @http_content_type
32
+ # @http_path_info
33
+ # @http_request_uri
34
+ # @http_query_string
35
+ # @http_post_content
36
+ # @http_headers
37
+
38
+ response = EM::DelegatedHttpResponse.new(self)
39
+ response.status = 200
40
+ response.content_type 'text/html'
41
+ response.content = '<center><h1>Hi there</h1></center>'
42
+ response.send_response
43
+ end
44
+ end
45
+
46
+ EM.run{
47
+ EM.start_server '0.0.0.0', 8080, MyHttpServer
48
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{eventmachine_httpserver}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Francis Cianfrocca"]
@@ -12,13 +12,12 @@ Gem::Specification.new do |s|
12
12
  s.email = %q{garbagecat10@gmail.com}
13
13
  s.extensions = ["ext/extconf.rb"]
14
14
  s.extra_rdoc_files = ["docs/COPYING", "docs/README", "docs/RELEASE_NOTES"]
15
- s.files = ["Rakefile", "docs/COPYING", "docs/README", "docs/RELEASE_NOTES", "eventmachine_httpserver.gemspec", "eventmachine_httpserver.gemspec.tmpl", "ext/extconf.rb", "ext/http.cpp", "ext/http.h", "ext/rubyhttp.cpp", "lib/evma_httpserver.rb", "lib/evma_httpserver/response.rb", "test/test_app.rb", "test/test_delegated.rb", "test/test_response.rb"]
16
- s.has_rdoc = true
15
+ s.files = ["README", "Rakefile", "docs/COPYING", "docs/README", "docs/RELEASE_NOTES", "eventmachine_httpserver.gemspec", "eventmachine_httpserver.gemspec.tmpl", "ext/extconf.rb", "ext/http.cpp", "ext/http.h", "ext/rubyhttp.cpp", "lib/evma_httpserver.rb", "lib/evma_httpserver/response.rb", "test/test_app.rb", "test/test_delegated.rb", "test/test_response.rb"]
17
16
  s.homepage = %q{http://rubyeventmachine.com}
18
17
  s.rdoc_options = ["--title", "EventMachine_HttpServer", "--main", "docs/README", "--line-numbers"]
19
18
  s.require_paths = ["lib"]
20
19
  s.required_ruby_version = Gem::Requirement.new("> 0.0.0")
21
- s.rubygems_version = %q{1.3.1}
20
+ s.rubygems_version = %q{1.3.4}
22
21
  s.summary = %q{EventMachine HTTP Server}
23
22
 
24
23
  if s.respond_to? :specification_version then
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{eventmachine_httpserver}
3
- s.version = "0.1.1"
3
+ s.version = "0.1.2"
4
4
 
5
5
  s.specification_version = 1 if s.respond_to? :specification_version=
6
6
 
@@ -20,4 +20,4 @@ Gem::Specification.new do |s|
20
20
  s.required_ruby_version = Gem::Requirement.new("> 0.0.0")
21
21
  s.rubygems_version = %q{1.3.1}
22
22
  s.summary = %q{EventMachine HTTP Server}
23
- end
23
+ end
data/ext/http.cpp CHANGED
@@ -170,6 +170,15 @@ void HttpConnection_t::ConsumeData (const char *data, int length)
170
170
  _Content = NULL;
171
171
  }
172
172
  RequestMethod = NULL;
173
+ #ifdef OS_WIN32
174
+ Cookie.erase(Cookie.begin(),Cookie.end());
175
+ IfNoneMatch.erase(IfNoneMatch.begin(),IfNoneMatch.end());
176
+ ContentType.erase(ContentType.begin(),ContentType.end());
177
+ PathInfo.erase(PathInfo.begin(),PathInfo.end());
178
+ RequestUri.erase(RequestUri.begin(),RequestUri.end());
179
+ QueryString.erase(QueryString.begin(),QueryString.end());
180
+ Protocol.erase(Protocol.begin(),Protocol.end());
181
+ #else
173
182
  Cookie.clear();
174
183
  IfNoneMatch.clear();
175
184
  ContentType.clear();
@@ -177,6 +186,7 @@ void HttpConnection_t::ConsumeData (const char *data, int length)
177
186
  RequestUri.clear();
178
187
  QueryString.clear();
179
188
  Protocol.clear();
189
+ #endif
180
190
 
181
191
  if (bSetEnvironmentStrings) {
182
192
  unsetenv ("REQUEST_METHOD");
@@ -460,7 +470,8 @@ bool HttpConnection_t::_InterpretRequest (const char *header)
460
470
  const char *questionmark = strchr (blank, '?');
461
471
  if (questionmark && (questionmark >= blank2))
462
472
  questionmark = NULL;
463
- const char *fragment = strpbrk ((questionmark ? (questionmark+1) : blank), "#;");
473
+ // const char *fragment = strpbrk ((questionmark ? (questionmark+1) : blank), "#;");
474
+ const char *fragment = strpbrk ((questionmark ? (questionmark+1) : blank), "#");
464
475
  if (fragment && (fragment >= blank2))
465
476
  fragment = NULL;
466
477
 
@@ -482,7 +493,11 @@ bool HttpConnection_t::_InterpretRequest (const char *header)
482
493
  string req (blank, fragment - blank);
483
494
  PathInfo = req.c_str();
484
495
  RequestUri = req.c_str();
496
+ #ifdef OS_WIN32
497
+ QueryString.erase(QueryString.begin(),QueryString.end());
498
+ #else
485
499
  QueryString.clear();
500
+ #endif
486
501
  if (bSetEnvironmentStrings) {
487
502
  setenv ("PATH_INFO", req.c_str(), true);
488
503
  setenv ("REQUEST_URI", req.c_str(), true);
@@ -494,7 +509,11 @@ bool HttpConnection_t::_InterpretRequest (const char *header)
494
509
  string req (blank, blank2 - blank);
495
510
  PathInfo = req.c_str();
496
511
  RequestUri = req.c_str();
512
+ #ifdef OS_WIN32
513
+ QueryString.erase(QueryString.begin(),QueryString.end());
514
+ #else
497
515
  QueryString.clear();
516
+ #endif
498
517
  if (bSetEnvironmentStrings) {
499
518
  setenv ("PATH_INFO", req.c_str(), true);
500
519
  setenv ("REQUEST_URI", req.c_str(), true);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine-eventmachine_httpserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -23,6 +23,7 @@ extra_rdoc_files:
23
23
  - docs/README
24
24
  - docs/RELEASE_NOTES
25
25
  files:
26
+ - README
26
27
  - Rakefile
27
28
  - docs/COPYING
28
29
  - docs/README
@@ -38,8 +39,9 @@ files:
38
39
  - test/test_app.rb
39
40
  - test/test_delegated.rb
40
41
  - test/test_response.rb
41
- has_rdoc: true
42
+ has_rdoc: false
42
43
  homepage: http://rubyeventmachine.com
44
+ licenses:
43
45
  post_install_message:
44
46
  rdoc_options:
45
47
  - --title
@@ -64,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
66
  requirements: []
65
67
 
66
68
  rubyforge_project:
67
- rubygems_version: 1.2.0
69
+ rubygems_version: 1.3.5
68
70
  signing_key:
69
71
  specification_version: 1
70
72
  summary: EventMachine HTTP Server