iodine 0.7.49 → 0.7.50

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dad2816193abeda90adf195c3c9cfcaa53eb9a1c5f1e4ad8364be45cd10bc2f
4
- data.tar.gz: 02e35b8bbdf6516d210bd8cfc012035a1de2ec3a783e4346152bead0186ba668
3
+ metadata.gz: 222b90cff0e761d924b2a3f7cba4f8914727cf87619602781a8a6ad3bc824e97
4
+ data.tar.gz: 3935cf93e8874392560949a07ad990d94501d4b31ddabb2e825ef3c6cbc41539
5
5
  SHA512:
6
- metadata.gz: bca7fb5be56837c4a729cef3f755ee4fa8a5a289d448961e01f9449a6e3d76865b03956d7525802a2a1c3768da61b4b8cf8a6088ca63ed57e3b966575e95fb51
7
- data.tar.gz: f2fcb35e2cd7452dbeb7fb20bbe5deb3f661e8a3f3ec387d878a858732a414d3d383320164a8a3164be0cdebf900a14360e60d87488c5d61e5b8105ada6270d8
6
+ metadata.gz: 736cac5605c0234d77390184460acc6771abac50de525ea4df9cc48026e5b58312afc55d336026901373f123fab59d6baa86314cf2d5955da094c1bdc669c4ac
7
+ data.tar.gz: 2229bccab50dd9b530338c3c326c6b52f90983e06210c2beb88ecb27dd57a66fcfca005155ae46c35724e938b62e7aceb47cec939d1fe2ea724235fc48816466
@@ -0,0 +1,42 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support documentation.
4
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
5
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
6
+
7
+ name: Building iodine
8
+
9
+ on:
10
+ push:
11
+ branches: [ "master" ]
12
+ pull_request:
13
+ branches: [ "master" ]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ test:
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ ruby-version: ['2.3', '2.7', '3.0', '3.2']
24
+ os: [ubuntu-latest, macos-latest] # , windows-latest
25
+ runs-on: ${{ matrix.os }}
26
+ steps:
27
+ - uses: actions/checkout@v3
28
+ - name: Set up Ruby # see https://github.com/ruby/setup-ruby#versioning)
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby-version }}
32
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
33
+ - name: Build and Test Iodine
34
+ run: |
35
+ echo CFLAGS = $CFLAGS
36
+ echo cflags = $cflags
37
+ echo HOME = $HOME
38
+ ruby -e 'puts Gem.default_dir'
39
+ bundle exec rake install
40
+ # env VERBOSE=1 bundle exec rspec --format documentation
41
+ # - name: Run tests
42
+ # run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -6,10 +6,18 @@ Please notice that this change log contains changes for upcoming releases as wel
6
6
 
7
7
  ## Changes:
8
8
 
9
+ #### Change log v.0.7.50
10
+
11
+ **Fix**: Fixes some compatibility issues with Rack 3.0. Credit to @taku0 for opening issue #131.
12
+
13
+ **Fix**: Fixes compilation on Ruby 3.x - deprecation of `rc_cData`. Credit to Mohammad A. Ali (@oldmoe) for opening issue #128.
14
+
9
15
  #### Change log v.0.7.49
10
16
 
11
17
  **Fix**: Fixes an issue where named arguments for `subscribe` might not be properly recognized.
12
18
 
19
+ **Security**: Fixes an issue where a malformed WebSocket continuation frame might crash a worker process. Credit to @fabio for exposing this issue and opening issue #127.
20
+
13
21
  #### Change log v.0.7.48 (2022-06-28)
14
22
 
15
23
  **Fix**: Fixes an issue with `pong` WebSocket frames when a client sends a WebSocket `ping`. Credit to Lucas Kuan (@lucaskuan) for finding this issue and for PR #124.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # iodine - Why Settle for a fast HTTP / WebSocket Server with native Pub/Sub?
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/dt/iodine.svg)](https://rubygems.org/gems/iodine)
4
- [![Build Status](https://travis-ci.org/boazsegev/iodine.svg?branch=master)](https://travis-ci.org/boazsegev/iodine)
4
+ [![Build Status](https://github.com/boazsegev/iodine/actions/workflows/ruby.yml/badge.svg)](https://github.com/boazsegev/iodine/actions/workflows/ruby.yml)
5
5
  [![Gem Version](https://badge.fury.io/rb/iodine.svg)](https://badge.fury.io/rb/iodine)
6
6
  [![Inline docs](http://inch-ci.org/github/boazsegev/iodine.svg?branch=master)](http://www.rubydoc.info/github/boazsegev/iodine/master/frames)
7
7
  [![GitHub](https://img.shields.io/badge/GitHub-Open%20Source-blue.svg)](https://github.com/boazsegev/iodine)
@@ -37,7 +37,7 @@ Since iodine wraps much of the [C facil.io framework](https://github.com/boazseg
37
37
 
38
38
  * Iodine is ideal for **Linux/Unix** based systems (i.e. macOS, Ubuntu, FreeBSD etc'), which are ideal for evented IO (while Windows and Solaris are better at IO *completion* events, which are very different).
39
39
 
40
- Iodine is a C extension for Ruby, developed and optimized for Ruby MRI 2.2.2 and up... it should support the whole Ruby 2.0 MRI family, but CI tests start at Ruby 2.2.2.
40
+ Iodine is a C extension for Ruby, developed and optimized for Ruby MRI 2.3 and up... it should support the whole Ruby 2.x and 3.x MRI family, but CI tests start at Ruby 2.3.
41
41
 
42
42
  **Note**: iodine does **not** support streaming when using Rack. It's recommended to avoid blocking the server when using `body.each` since the `each` loop will block the iodine's thread until it's finished and iodine won't send any data before the loop is done.
43
43
 
data/examples/rack3.ru ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ # adjusted from the code suggested by @taku0 (GitHub issue #131)
4
+ require 'rack'
5
+ require 'iodine'
6
+
7
+ run { |env|
8
+ response = Rack::Response.new(nil, 204)
9
+ response.set_cookie('aaa', 'aaa')
10
+ response.set_cookie('bbb', 'bbb')
11
+ response.finish
12
+ }
data/exe/iodine CHANGED
@@ -16,6 +16,7 @@ begin
16
16
  end
17
17
  end
18
18
  rescue LoadError
19
+ puts "WARNING: The gam `rack` wasn't loaded before iodine started loading the rack app, using custom loader."
19
20
  module Iodine
20
21
  module Base
21
22
  module Rack
@@ -133,8 +134,9 @@ rescue LoadError
133
134
  # end
134
135
  #
135
136
  # run Heartbeat
136
- def run(app)
137
- @run = app
137
+ def run(app = nil, &block)
138
+ raise ArgumentError, "Both app and block given!" if app && block_given?
139
+ @run = app || block
138
140
  end
139
141
 
140
142
  # Takes a lambda or block that is used to warm-up the application.
@@ -214,28 +216,29 @@ module Iodine
214
216
 
215
217
  def self.try_file filename
216
218
  return nil unless File.exist? filename
217
- return Iodine::Base::Rack::Builder.parse_file filename
219
+ result = Iodine::Base::Rack::Builder.parse_file filename
220
+ return result[0] if(result.is_a?(Array))
221
+ return result
218
222
  end
219
223
 
220
224
  def self.get_app_opts
221
- app, opt = nil, nil
225
+ app, opt = nil, Hash.new
222
226
  filename = Iodine::DEFAULT_SETTINGS[:filename_]
223
227
  if filename
224
- app, opt = try_file filename
225
- app, opt = try_file "#{filename}.ru" unless opt
226
- unless opt
228
+ app = try_file(filename)
229
+ app = try_file("#{filename}.ru") unless app
230
+ unless app
227
231
  puts "* Couldn't find #{filename}\n testing for config.ru\n"
228
- app, opt = try_file "config.ru"
232
+ app = try_file "config.ru"
229
233
  end
230
234
  else
231
- app, opt = try_file "config.ru";
235
+ app = try_file "config.ru";
232
236
  end
233
237
 
234
- unless opt
238
+ unless app
235
239
  puts "WARNING: Ruby application not found#{ filename ? " - missing both #{filename} and config.ru" : " - missing config.ru"}."
236
240
  if Iodine::DEFAULT_SETTINGS[:public]
237
241
  puts " Running only static file service."
238
- opt = Hash.new
239
242
  app = Proc.new { [404, {}, "Not Found!"] }
240
243
  else
241
244
  puts "\nERROR: Couldn't run Ruby application, check command line arguments."
@@ -1,4 +1,5 @@
1
1
  require 'mkmf'
2
+ require 'fileutils'
2
3
 
3
4
  # Test polling
4
5
  def iodine_test_polling_support
@@ -903,7 +903,8 @@ void iodine_connection_init(void) {
903
903
  IodineStore.add(RAWSymbol);
904
904
 
905
905
  // define the Connection Class and it's methods
906
- ConnectionKlass = rb_define_class_under(IodineModule, "Connection", rb_cData);
906
+ ConnectionKlass =
907
+ rb_define_class_under(IodineModule, "Connection", rb_cObject);
907
908
  rb_define_alloc_func(ConnectionKlass, iodine_connection_data_alloc_c);
908
909
  rb_define_method(ConnectionKlass, "write", iodine_connection_write, 1);
909
910
  rb_define_method(ConnectionKlass, "close", iodine_connection_close, 0);
@@ -477,6 +477,10 @@ Handling the HTTP response
477
477
  static int for_each_header_data(VALUE key, VALUE val, VALUE h_) {
478
478
  http_s *h = (http_s *)h_;
479
479
  // fprintf(stderr, "For_each - headers\n");
480
+ if (TYPE(val) == T_NIL)
481
+ return ST_CONTINUE;
482
+ if (TYPE(val) == T_ARRAY)
483
+ goto array_style_multi_value;
480
484
  if (TYPE(key) != T_STRING)
481
485
  key = IodineCaller.call(key, iodine_to_s_id);
482
486
  if (TYPE(key) != T_STRING)
@@ -515,6 +519,14 @@ static int for_each_header_data(VALUE key, VALUE val, VALUE h_) {
515
519
  fiobj_free(name);
516
520
  // no errors, return 0
517
521
  return ST_CONTINUE;
522
+
523
+ array_style_multi_value:
524
+ for (size_t i = 0, end = RARRAY_LEN(val); i < end; ++i) {
525
+ if (for_each_header_data(key, RARRAY_AREF(val, i), h_) == ST_CONTINUE)
526
+ continue;
527
+ return ST_STOP;
528
+ }
529
+ return ST_CONTINUE;
518
530
  }
519
531
 
520
532
  // writes the body to the response object
@@ -940,15 +952,15 @@ intptr_t iodine_http_listen(iodine_connection_args_s args){
940
952
  support_xsendfile = 1;
941
953
  }
942
954
  IodineStore.add(args.handler);
943
- #ifdef __MINGW32__
944
- intptr_t uuid = http_listen(
955
+ #ifdef __MINGW32__
956
+ intptr_t uuid = http_listen(
945
957
  args.port.data, args.address.data, .on_request = on_rack_request,
946
958
  .on_upgrade = on_rack_upgrade, .udata = (void *)args.handler,
947
959
  .timeout = args.timeout, .ws_timeout = args.ping,
948
960
  .ws_max_msg_size = args.max_msg, .max_header_size = args.max_headers,
949
961
  .on_finish = free_iodine_http, .log = args.log,
950
962
  .max_body_size = args.max_body, .public_folder = args.public.data);
951
- #else
963
+ #else
952
964
  intptr_t uuid = http_listen(
953
965
  args.port.data, args.address.data, .on_request = on_rack_request,
954
966
  .on_upgrade = on_rack_upgrade, .udata = (void *)args.handler,
@@ -956,7 +968,7 @@ intptr_t iodine_http_listen(iodine_connection_args_s args){
956
968
  .ws_max_msg_size = args.max_msg, .max_header_size = args.max_headers,
957
969
  .on_finish = free_iodine_http, .log = args.log,
958
970
  .max_body_size = args.max_body, .public_folder = args.public.data);
959
- #endif
971
+ #endif
960
972
  if (uuid == -1)
961
973
  return uuid;
962
974
 
@@ -1066,11 +1078,11 @@ intptr_t iodine_ws_connect(iodine_connection_args_s args) {
1066
1078
  FIOBJ url_tmp = FIOBJ_INVALID;
1067
1079
  if (!args.url.data) {
1068
1080
  url_tmp = fiobj_str_buf(64);
1069
- #ifndef __MINGW32__
1081
+ #ifndef __MINGW32__
1070
1082
  if (args.tls)
1071
1083
  fiobj_str_write(url_tmp, "wss://", 6);
1072
1084
  else
1073
- #endif
1085
+ #endif
1074
1086
  fiobj_str_write(url_tmp, "ws://", 5);
1075
1087
  if (!is_unix_socket) {
1076
1088
  fiobj_str_write(url_tmp, args.address.data, args.address.len);
@@ -1087,11 +1099,11 @@ intptr_t iodine_ws_connect(iodine_connection_args_s args) {
1087
1099
  }
1088
1100
 
1089
1101
  #ifdef __MINGW32__
1090
- intptr_t uuid = http_connect(
1091
- args.url.data, (is_unix_socket ? args.address.data : NULL),
1092
- .udata = request_data_create(&args),
1093
- .on_response = ws_client_http_connected,
1094
- .on_finish = ws_client_http_connection_finished);
1102
+ intptr_t uuid =
1103
+ http_connect(args.url.data, (is_unix_socket ? args.address.data : NULL),
1104
+ .udata = request_data_create(&args),
1105
+ .on_response = ws_client_http_connected,
1106
+ .on_finish = ws_client_http_connection_finished);
1095
1107
  #else
1096
1108
  intptr_t uuid = http_connect(
1097
1109
  args.url.data, (is_unix_socket ? args.address.data : NULL),
@@ -558,7 +558,7 @@ void iodine_init_mustache(void) {
558
558
  rb_global_variable(&filename_id);
559
559
  rb_global_variable(&data_id);
560
560
  rb_global_variable(&template_id);
561
- VALUE tmp = rb_define_class_under(IodineModule, "Mustache", rb_cData);
561
+ VALUE tmp = rb_define_class_under(IodineModule, "Mustache", rb_cObject);
562
562
  rb_define_alloc_func(tmp, iodine_mustache_data_alloc_c);
563
563
  rb_define_method(tmp, "initialize", iodine_mustache_new, -1);
564
564
  rb_define_method(tmp, "render", iodine_mustache_render, 1);
@@ -132,7 +132,7 @@ struct IodineStorage_s IodineStore = {
132
132
  void iodine_storage_init(void) {
133
133
  fio_store_capa_require(&iodine_storage, 512);
134
134
  VALUE tmp =
135
- rb_define_class_under(rb_cObject, "IodineObjectStorage", rb_cData);
135
+ rb_define_class_under(rb_cObject, "IodineObjectStorage", rb_cObject);
136
136
  VALUE storage_obj =
137
137
  TypedData_Wrap_Struct(tmp, &storage_type_struct, &iodine_storage);
138
138
  // rb_global_variable(&iodine_storage_obj);
@@ -241,7 +241,7 @@ void iodine_init_tls(void) {
241
241
  IODINE_MAKE_SYM(private_key);
242
242
  IODINE_MAKE_SYM(password);
243
243
 
244
- IodineTLSClass = rb_define_class_under(IodineModule, "TLS", rb_cData);
244
+ IodineTLSClass = rb_define_class_under(IodineModule, "TLS", rb_cObject);
245
245
  rb_define_alloc_func(IodineTLSClass, iodine_tls_data_alloc_c);
246
246
  rb_define_method(IodineTLSClass, "initialize", iodine_tls_new, -1);
247
247
  rb_define_method(IodineTLSClass, "use_certificate",
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '0.7.49'.freeze
2
+ VERSION = '0.7.50'.freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'iodine' unless defined?(::Iodine::VERSION)
2
2
 
3
3
  module Iodine
4
- # Iodine's {Iodine::Rack} module provides a Rack complient interface (connecting Iodine to Rack) for an HTTP and Websocket Server.
4
+ # Iodine's {Iodine::Rack} module provides a Rack compliant interface (connecting Iodine to Rack) for an HTTP and Websocket Server.
5
5
  module Rack
6
6
 
7
7
  # Runs a Rack app, as par the Rack handler requirements.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.49
4
+ version: 0.7.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-12 00:00:00.000000000 Z
11
+ date: 2022-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -122,9 +122,9 @@ extensions:
122
122
  extra_rdoc_files: []
123
123
  files:
124
124
  - ".github/ISSUE_TEMPLATE/bug_report.md"
125
+ - ".github/workflows/ruby.yml"
125
126
  - ".gitignore"
126
127
  - ".rspec"
127
- - ".travis.yml"
128
128
  - ".yardopts"
129
129
  - CHANGELOG.md
130
130
  - Gemfile
@@ -148,6 +148,7 @@ files:
148
148
  - examples/etag.ru
149
149
  - examples/hello.ru
150
150
  - examples/pubsub_engine.ru
151
+ - examples/rack3.ru
151
152
  - examples/redis.ru
152
153
  - examples/shootout.ru
153
154
  - examples/sub-protocols.ru
@@ -245,7 +246,7 @@ licenses:
245
246
  metadata:
246
247
  allowed_push_host: https://rubygems.org
247
248
  post_install_message: |-
248
- Thank you for installing Iodine 0.7.49.
249
+ Thank you for installing Iodine 0.7.50.
249
250
  Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations).
250
251
  rdoc_options: []
251
252
  require_paths:
@@ -268,7 +269,7 @@ requirements:
268
269
  - Ruby >= 2.5.0 recommended.
269
270
  - TLS requires OpenSSL >= 1.1.0.
270
271
  - Or Windows with Ruby >= 3.0.0 build with MingW and MingW as compiler.
271
- rubygems_version: 3.2.32
272
+ rubygems_version: 3.3.7
272
273
  signing_key:
273
274
  specification_version: 4
274
275
  summary: iodine - a fast HTTP / Websocket Server with Pub/Sub support, optimized for
data/.travis.yml DELETED
@@ -1,32 +0,0 @@
1
- language: ruby
2
- arch:
3
- - amd64
4
- - arm64
5
- os:
6
- - linux
7
- # - osx
8
- before_install:
9
- - gem install bundler -v 1.10.6
10
- - bundle install
11
- rvm:
12
- - 2.7.1
13
- - 2.6.5
14
- - 2.5.7
15
- - 2.4.9
16
- - 2.3.8
17
- - 2.2.2
18
- notifications:
19
- email: false
20
- sudo: required
21
- dist: xenial
22
- addons:
23
- apt:
24
- sources:
25
- - ubuntu-toolchain-r-test
26
- packages:
27
- - gcc
28
- script:
29
- - echo CFLAGS = $CFLAGS
30
- - echo cflags = $cflags
31
- - bundle exec rake install
32
- - env VERBOSE=1 bundle exec rspec --format documentation