agoo 0.9.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of agoo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4972cbbcab2bb5e6efd12fdbe709e6e3b5e3c21edba29bd9abf66e6aecb5dcf5
4
- data.tar.gz: 6a5d2c4c783a19c4452ea65b5509a8c9acce86bb15dcdacef805615084c07c6a
3
+ metadata.gz: ec0e1021cff3ef520275f242403861641910567fddf30d07d0df0f4d456e2d1f
4
+ data.tar.gz: 7a6058474e50a04e1e068cf4911762079d9a7ec0777087914b1a40faf61b2ff6
5
5
  SHA512:
6
- metadata.gz: dded79dd9e1850504e766708f3c646ecc2930991a5cfbf3c470533a1881e606404aaf75abf0ae1f81ec161d4caac3b85268f0504c11b748bb024b57194034b67
7
- data.tar.gz: ec6ec4aa3199cfb1aedea0203f2ec33602884c134b7144f2febcf2b7009cd069c54439b9ae90485a68e12ec3f18fcf37d36b2e96928744aa6937fe8e28e0f61a
6
+ metadata.gz: 03fa2278f4a6b70d1495577086ed15015f70ab7600a46dc02d6d4e91d996bfdcc1e818217a9043b83d3490c637ab53859402dead80524ea2bf0319812a536c2a
7
+ data.tar.gz: 2517add46e2130c993aee42e69fddc05b27b62d6582217c6f6f24cae585c53051536b9bca1b914e900deba6963dd2f70a53496a77993a7310308774e797149c5
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # agoo
2
2
 
3
3
  [![Build Status](https://img.shields.io/travis/ohler55/agoo/master.svg)](http://travis-ci.org/ohler55/agoo?branch=master)
4
+ [![Gem Version](https://badge.fury.io/rb/agoo.svg)](https://badge.fury.io/rb/agoo)
4
5
 
5
6
  A High Performance HTTP Server for Ruby
6
7
 
@@ -35,9 +36,9 @@ gem install agoo
35
36
  Agoo is Japanese for a type of flying fish. This gem flies. It is a high
36
37
  performance HTTP server that serves static resource at hundreds of thousands
37
38
  of fetchs per second. A a simple hello world Ruby handler at over 100,000
38
- requests per second on a desktop computer. That places Agoo at about 80 times
39
+ requests per second on a desktop computer. That places Agoo at about 85 times
39
40
  faster than Sinatra and 1000 times faster than Rails. In both cases the
40
- latency was an order of magnitude lower or more. Checkout the benchmarks on <a
41
+ latency was two orders of magnitude lower or more. Checkout the benchmarks on <a
41
42
  href="http://opo.technology/benchmarks.html#web_benchmarks">OpO
42
43
  benchmarks</a>. Note that the benchmarks had to use a C program called _hose_
43
44
  from the <a href="http://opo.technology/index.html">OpO</a> downloads to hit
@@ -229,6 +229,12 @@ con_header_read(Con c) {
229
229
  Res res;
230
230
 
231
231
  if (NULL == p) {
232
+ if (NULL != server->hook404) {
233
+ // There would be too many parameters to pass to a
234
+ // separate function so just goto the hook processing.
235
+ hook = server->hook404;
236
+ goto HOOKED;
237
+ }
232
238
  return bad_request(c, 404, __LINE__);
233
239
  }
234
240
  if (NULL == (res = res_create())) {
@@ -250,6 +256,7 @@ con_header_read(Con c) {
250
256
  return true;
251
257
  }
252
258
  }
259
+ HOOKED:
253
260
  // Create request and populate.
254
261
  mlen = hend - c->buf + 4 + clen;
255
262
  if (NULL == (c->req = (Req)malloc(mlen + sizeof(struct _Req) - 8 + 1))) {
@@ -554,7 +554,7 @@ request_init(VALUE mod) {
554
554
  rack_run_once_val = rb_str_new_cstr("rack.run_once"); rb_gc_register_address(&rack_run_once_val);
555
555
  rack_url_scheme_val = rb_str_new_cstr("rack.url_scheme"); rb_gc_register_address(&rack_url_scheme_val);
556
556
  rack_version_val = rb_str_new_cstr("rack.version"); rb_gc_register_address(&rack_version_val);
557
- rack_version_val_val = rb_str_new_cstr("2.0.3"); rb_gc_register_address(&rack_version_val_val);
557
+ rack_version_val_val = rb_str_new_cstr("1.3"); rb_gc_register_address(&rack_version_val_val);
558
558
  request_method_val = rb_str_new_cstr("REQUEST_METHOD"); rb_gc_register_address(&request_method_val);
559
559
  script_name_val = rb_str_new_cstr("SCRIPT_NAME"); rb_gc_register_address(&script_name_val);
560
560
  server_name_val = rb_str_new_cstr("SERVER_NAME"); rb_gc_register_address(&server_name_val);
@@ -39,7 +39,9 @@ response_fill(Response res, char *buf) {
39
39
  *buf++ = '\n';
40
40
  if (NULL != res->body) {
41
41
  memcpy(buf, res->body, res->blen);
42
+ buf += res->blen;
42
43
  }
44
+ *buf = '\0';
43
45
  }
44
46
 
45
47
  static void
@@ -851,10 +851,30 @@ handle(VALUE self, VALUE method, VALUE pattern, VALUE handler) {
851
851
  } else {
852
852
  server->hooks = hook;
853
853
  }
854
+ rb_gc_register_address(&hook->handler);
854
855
  }
855
856
  return Qnil;
856
857
  }
857
858
 
859
+ /* Document-method: handle_not_found
860
+ *
861
+ * call-seq: not_found_handle(handler)
862
+ *
863
+ * Registers a handler to be called when no other hook is found and no static
864
+ * file is found.
865
+ */
866
+ static VALUE
867
+ handle_not_found(VALUE self, VALUE handler) {
868
+ Server server = (Server)DATA_PTR(self);
869
+
870
+ if (NULL == (server->hook404 = hook_create(GET, "/", handler))) {
871
+ rb_raise(rb_eStandardError, "out of memory.");
872
+ }
873
+ rb_gc_register_address(&server->hook404->handler);
874
+
875
+ return Qnil;
876
+ }
877
+
858
878
  /* Document-class: Agoo::Server
859
879
  *
860
880
  * An HTTP server that support the rack API as well as some other optimized
@@ -884,6 +904,7 @@ server_init(VALUE mod) {
884
904
  rb_define_method(server_class, "log_flush", server_log_flush, 1);
885
905
 
886
906
  rb_define_method(server_class, "handle", handle, 3);
907
+ rb_define_method(server_class, "handle_not_found", handle_not_found, 1);
887
908
 
888
909
  call_id = rb_intern("call");
889
910
  each_id = rb_intern("each");
@@ -38,6 +38,7 @@ typedef struct _Server {
38
38
  struct _Cache pages;
39
39
 
40
40
  Hook hooks;
41
+ Hook hook404;
41
42
  struct _Queue eval_queue;
42
43
 
43
44
  VALUE *eval_threads; // Qnil terminated
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '0.9.1'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -108,7 +108,7 @@ class BaseHandlerTest < Minitest::Test
108
108
  "rack.multithread" => false,
109
109
  "rack.run_once" => false,
110
110
  "rack.url_scheme" => "http",
111
- "rack.version" => "2.0.3",
111
+ "rack.version" => "1.3",
112
112
  }
113
113
  expect.each_pair { |k,v|
114
114
  if v.nil?
@@ -104,7 +104,7 @@ class RackHandlerTest < Minitest::Test
104
104
  "rack.multithread" => false,
105
105
  "rack.run_once" => false,
106
106
  "rack.url_scheme" => "http",
107
- "rack.version" => "2.0.3",
107
+ "rack.version" => "1.3",
108
108
  }
109
109
  expect.each_pair { |k,v|
110
110
  if v.nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-28 00:00:00.000000000 Z
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -152,8 +152,8 @@ signing_key:
152
152
  specification_version: 4
153
153
  summary: An HTTP server
154
154
  test_files:
155
- - test/base_handler_test.rb
156
- - test/log_test.rb
155
+ - test/tests.rb
157
156
  - test/rack_handler_test.rb
157
+ - test/base_handler_test.rb
158
158
  - test/static_test.rb
159
- - test/tests.rb
159
+ - test/log_test.rb