ds9 1.3.1 → 1.4.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 675cfb91dad1dd9337150425144870db64e880c9
4
- data.tar.gz: 31fa19e3c643ce1a425cb7c97b2fa6e145fb69d4
2
+ SHA256:
3
+ metadata.gz: e8b2fb157e8388f8d381c77c4676c9d179217648a1712a96e036eebfe1fdd17d
4
+ data.tar.gz: 73283b1afcac1e5703a1d121c0dbe76c17b965b950eae9207ec0d62cf03bcecb
5
5
  SHA512:
6
- metadata.gz: 5023590043ecd16dc8f9f004cb7c38e0b479806459c0716e108ba15160f3eb88d8d15fa0349118817aa7414d7878ece680c8dc97059bc102dfb2e13b2fa3b187
7
- data.tar.gz: ed434905dc9b8129f0c812cec3a752b77618a61c157698e46c2d2b3b22221ac1a28145a089d222e31f37258e42221b5cdd9b841589a266e26a12e813e1f12b80
6
+ metadata.gz: 8df87ef9a3b64d895c28f73c102cf4269ef5018b338e873d1f990142deaeca2ec94f6a429610f9ba45d2f3c86807c5009290abe79ee88e46adc77dd8ff86fbbb
7
+ data.tar.gz: ab524840e37027405339a7e9a64c58503322b82ce56893237abe818507229ad3930adaabfbc4cf29e4ab57238f98bb6cf3a0dfb24a32893b588d4bcac77bac86
@@ -0,0 +1,35 @@
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
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake test
data/Gemfile CHANGED
@@ -1 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
1
3
  gemspec
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/extensiontask"
3
+ require "rake/testtask"
3
4
 
4
5
  task default: :compile
5
6
 
@@ -9,4 +10,9 @@ Rake::ExtensionTask.new("ds9") do |t|
9
10
  t.lib_dir = "lib"
10
11
  end
11
12
 
13
+ Rake::TestTask.new('test' => 'compile') do |t|
14
+ t.libs << 'test'
15
+ t.verbose = true
16
+ end
17
+
12
18
  # vim: syntax=ruby
data/ext/ds9/ds9.c CHANGED
@@ -23,7 +23,8 @@ ID id_on_header,
23
23
  id_on_stream_close,
24
24
  id_on_data_chunk_recv,
25
25
  id_on_data_source_read,
26
- id_before_frame_send;
26
+ id_before_frame_send,
27
+ id_eof_p;
27
28
 
28
29
  #define CheckSelf(ptr) \
29
30
  if (NULL == (ptr)) \
@@ -157,7 +158,7 @@ static ssize_t recv_callback(nghttp2_session *session, uint8_t *buf,
157
158
  VALUE ret;
158
159
  ssize_t len;
159
160
 
160
- ret = rb_funcall(self, id_recv_event, 1, INT2NUM(length));
161
+ ret = rb_funcall(self, id_recv_event, 1, ULONG2NUM(length));
161
162
 
162
163
  if (FIXNUM_P(ret)) {
163
164
  return NUM2INT(ret);
@@ -270,7 +271,7 @@ static ssize_t rb_data_read_callback(nghttp2_session *session,
270
271
  ssize_t len;
271
272
 
272
273
  ret = rb_funcall(self, id_on_data_source_read, 2, INT2NUM(stream_id),
273
- INT2NUM(length));
274
+ ULONG2NUM(length));
274
275
 
275
276
  if (NIL_P(ret)) {
276
277
  *data_flags |= NGHTTP2_DATA_FLAG_EOF;
@@ -320,8 +321,9 @@ struct hash_copy_ctx {
320
321
  };
321
322
 
322
323
  static int
323
- hash_copy_i(VALUE name, VALUE value, struct hash_copy_ctx * ctx)
324
+ hash_copy_i(VALUE name, VALUE value, VALUE arg)
324
325
  {
326
+ struct hash_copy_ctx *ctx = (struct hash_copy_ctx *)arg;
325
327
  nghttp2_nv * head = ctx->head;
326
328
 
327
329
  head->name = (uint8_t *)StringValuePtr(name);
@@ -341,7 +343,7 @@ static void copy_hash_to_nv(VALUE hash, nghttp2_nv * head, size_t niv)
341
343
  struct hash_copy_ctx copy_ctx;
342
344
  copy_ctx.head = head;
343
345
 
344
- rb_hash_foreach(hash, hash_copy_i, &copy_ctx);
346
+ rb_hash_foreach(hash, hash_copy_i, (VALUE)&copy_ctx);
345
347
  }
346
348
 
347
349
  static VALUE allocate_session(VALUE klass)
@@ -349,10 +351,11 @@ static VALUE allocate_session(VALUE klass)
349
351
  return TypedData_Wrap_Struct(klass, &ds9_session_type, 0);
350
352
  }
351
353
 
352
- static VALUE client_init_internals(VALUE self, VALUE cb)
354
+ static VALUE client_init_internals(VALUE self, VALUE cb, VALUE opt)
353
355
  {
354
356
  nghttp2_session_callbacks *callbacks;
355
357
  nghttp2_session *session;
358
+ nghttp2_option *option;
356
359
  nghttp2_mem mem = {
357
360
  NULL,
358
361
  wrap_xmalloc,
@@ -362,17 +365,18 @@ static VALUE client_init_internals(VALUE self, VALUE cb)
362
365
  };
363
366
 
364
367
  TypedData_Get_Struct(cb, nghttp2_session_callbacks, &ds9_callbacks_type, callbacks);
365
-
366
- nghttp2_session_client_new3(&session, callbacks, (void *)self, NULL, &mem);
368
+ option = UnwrapDS9Option(opt);
369
+ nghttp2_session_client_new3(&session, callbacks, (void *)self, option, &mem);
367
370
  DATA_PTR(self) = session;
368
371
 
369
372
  return self;
370
373
  }
371
374
 
372
- static VALUE server_init_internals(VALUE self, VALUE cb)
375
+ static VALUE server_init_internals(VALUE self, VALUE cb, VALUE opt)
373
376
  {
374
377
  nghttp2_session_callbacks *callbacks;
375
378
  nghttp2_session *session;
379
+ nghttp2_option *option;
376
380
  nghttp2_mem mem = {
377
381
  NULL,
378
382
  wrap_xmalloc,
@@ -382,8 +386,8 @@ static VALUE server_init_internals(VALUE self, VALUE cb)
382
386
  };
383
387
 
384
388
  TypedData_Get_Struct(cb, nghttp2_session_callbacks, &ds9_callbacks_type, callbacks);
385
-
386
- nghttp2_session_server_new3(&session, callbacks, (void *)self, NULL, &mem);
389
+ option = UnwrapDS9Option(opt);
390
+ nghttp2_session_server_new3(&session, callbacks, (void *)self, option, &mem);
387
391
  DATA_PTR(self) = session;
388
392
 
389
393
  return self;
@@ -487,6 +491,7 @@ static VALUE session_submit_trailer(VALUE self, VALUE stream_id, VALUE trailers)
487
491
  break;
488
492
  default:
489
493
  Check_Type(trailers, T_ARRAY);
494
+ UNREACHABLE;
490
495
  }
491
496
 
492
497
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -538,7 +543,7 @@ static VALUE session_receive(VALUE self)
538
543
 
539
544
  static VALUE session_mem_receive(VALUE self, VALUE buf)
540
545
  {
541
- int rv;
546
+ ssize_t rv;
542
547
  nghttp2_session *session;
543
548
 
544
549
  TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
@@ -546,10 +551,10 @@ static VALUE session_mem_receive(VALUE self, VALUE buf)
546
551
 
547
552
  rv = nghttp2_session_mem_recv(session, (const uint8_t *)StringValuePtr(buf), RSTRING_LEN(buf));
548
553
  if (rv < 0) {
549
- explode(rv);
554
+ explode((int)rv);
550
555
  }
551
556
 
552
- return INT2NUM(rv);
557
+ return ULONG2NUM(rv);
553
558
  }
554
559
 
555
560
  static VALUE session_mem_send(VALUE self)
@@ -568,7 +573,7 @@ static VALUE session_mem_send(VALUE self)
568
573
  }
569
574
 
570
575
  if (rv < 0) {
571
- explode(rv);
576
+ explode((int)rv);
572
577
  }
573
578
 
574
579
  return rb_str_new((const char *)data, rv);
@@ -581,27 +586,33 @@ static VALUE session_outbound_queue_size(VALUE self)
581
586
  TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
582
587
  CheckSelf(session);
583
588
 
584
- return INT2NUM(nghttp2_session_get_outbound_queue_size(session));
589
+ return ULONG2NUM(nghttp2_session_get_outbound_queue_size(session));
585
590
  }
586
591
 
587
592
  static ssize_t
588
593
  ruby_read(nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t length,
589
594
  uint32_t *data_flags, nghttp2_data_source *source, void *user_data)
590
595
  {
591
- VALUE ret = rb_funcall(source->ptr, rb_intern("read"), 1, INT2NUM(length));
596
+ VALUE body = (VALUE)source->ptr;
597
+ VALUE ret = rb_funcall(body, rb_intern("read"), 1, ULONG2NUM(length));
592
598
 
593
- if (NIL_P(ret)) {
594
- VALUE self = (VALUE)user_data;
595
- rb_funcall(self, rb_intern("remove_post_buffer"), 1, INT2NUM(stream_id));
596
- *data_flags |= NGHTTP2_DATA_FLAG_EOF;
597
- return 0;
598
- } else if (FIXNUM_P(ret)) {
599
+ if (FIXNUM_P(ret)) {
599
600
  ssize_t err = NUM2INT(ret);
600
601
  if (err == NGHTTP2_ERR_DEFERRED) {
601
602
  return err;
602
603
  }
603
604
  }
604
605
 
606
+ if (NIL_P(ret) || (rb_respond_to(body, id_eof_p) && RTEST(rb_funcall(body, id_eof_p, 0)))) {
607
+ VALUE self = (VALUE)user_data;
608
+ rb_funcall(self, rb_intern("remove_post_buffer"), 1, INT2NUM(stream_id));
609
+ *data_flags |= NGHTTP2_DATA_FLAG_EOF;
610
+ }
611
+
612
+ if (NIL_P(ret)) {
613
+ return 0;
614
+ }
615
+
605
616
  Check_Type(ret, T_STRING);
606
617
  memcpy(buf, RSTRING_PTR(ret), RSTRING_LEN(ret));
607
618
  return RSTRING_LEN(ret);
@@ -633,8 +644,8 @@ file_read(nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t leng
633
644
 
634
645
  static VALUE session_submit_request(VALUE self, VALUE settings, VALUE body)
635
646
  {
636
- size_t niv, i;
637
- nghttp2_nv *nva, *head;
647
+ size_t niv;
648
+ nghttp2_nv *nva;
638
649
  nghttp2_session *session;
639
650
  nghttp2_data_provider provider;
640
651
  int rv;
@@ -655,6 +666,7 @@ static VALUE session_submit_request(VALUE self, VALUE settings, VALUE body)
655
666
  break;
656
667
  default:
657
668
  Check_Type(settings, T_ARRAY);
669
+ UNREACHABLE;
658
670
  }
659
671
 
660
672
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -671,7 +683,7 @@ static VALUE session_submit_request(VALUE self, VALUE settings, VALUE body)
671
683
  provider.source.ptr = rb_file;
672
684
  provider.read_callback = file_read;
673
685
  } else {
674
- provider.source.ptr = body;
686
+ provider.source.ptr = (void *)body;
675
687
  provider.read_callback = ruby_read;
676
688
  }
677
689
 
@@ -826,7 +838,7 @@ static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
826
838
  {
827
839
  nghttp2_session *session;
828
840
  size_t niv;
829
- nghttp2_nv *nva, *head;
841
+ nghttp2_nv *nva;
830
842
  nghttp2_data_provider provider;
831
843
  int rv;
832
844
  copy_header_func_t copy_func;
@@ -846,6 +858,7 @@ static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
846
858
  break;
847
859
  default:
848
860
  Check_Type(headers, T_ARRAY);
861
+ UNREACHABLE;
849
862
  }
850
863
 
851
864
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -868,7 +881,7 @@ static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
868
881
  static VALUE server_submit_headers(VALUE self, VALUE stream_id, VALUE headers) {
869
882
  nghttp2_session *session;
870
883
  size_t niv;
871
- nghttp2_nv *nva, *head;
884
+ nghttp2_nv *nva;
872
885
  int rv;
873
886
  copy_header_func_t copy_func;
874
887
 
@@ -887,6 +900,7 @@ static VALUE server_submit_headers(VALUE self, VALUE stream_id, VALUE headers) {
887
900
  break;
888
901
  default:
889
902
  Check_Type(headers, T_ARRAY);
903
+ UNREACHABLE;
890
904
  }
891
905
 
892
906
  nva = xcalloc(niv, sizeof(nghttp2_nv));
@@ -1010,6 +1024,7 @@ void Init_ds9(void)
1010
1024
  mDS9 = rb_define_module("DS9");
1011
1025
 
1012
1026
  Init_ds9_frames(mDS9);
1027
+ Init_ds9_option(mDS9);
1013
1028
 
1014
1029
  rb_define_const(mDS9, "PROTO_VERSION_ID", rb_str_new(NGHTTP2_PROTO_VERSION_ID, NGHTTP2_PROTO_VERSION_ID_LEN));
1015
1030
 
@@ -1027,6 +1042,7 @@ void Init_ds9(void)
1027
1042
  rb_define_const(mDS9, "ERR_WOULDBLOCK", INT2NUM(NGHTTP2_ERR_WOULDBLOCK));
1028
1043
  rb_define_const(mDS9, "ERR_EOF", INT2NUM(NGHTTP2_ERR_EOF));
1029
1044
  rb_define_const(mDS9, "ERR_DEFERRED", INT2NUM(NGHTTP2_ERR_DEFERRED));
1045
+ rb_define_const(mDS9, "ERR_BAD_CLIENT_MAGIC", INT2NUM(NGHTTP2_ERR_BAD_CLIENT_MAGIC));
1030
1046
  rb_define_const(mDS9, "NO_ERROR", INT2NUM(NGHTTP2_NO_ERROR));
1031
1047
  rb_define_const(mDS9, "DEFAULT_WEIGHT", INT2NUM(NGHTTP2_DEFAULT_WEIGHT));
1032
1048
  rb_define_const(mDS9, "MAX_WEIGHT", INT2NUM(NGHTTP2_MAX_WEIGHT));
@@ -1039,7 +1055,7 @@ void Init_ds9(void)
1039
1055
 
1040
1056
  rb_define_singleton_method(mDS9, "nghttp_version", rb_nghttp_version, 0);
1041
1057
 
1042
- cDS9Callbacks = rb_define_class_under(mDS9, "Callbacks", rb_cData);
1058
+ cDS9Callbacks = rb_define_class_under(mDS9, "Callbacks", rb_cObject);
1043
1059
 
1044
1060
  cDS9Session = rb_define_class_under(mDS9, "Session", rb_cObject);
1045
1061
  cDS9Client = rb_define_class_under(mDS9, "Client", cDS9Session);
@@ -1065,8 +1081,8 @@ void Init_ds9(void)
1065
1081
 
1066
1082
  rb_define_private_method(cDS9Session, "submit_request", session_submit_request, 2);
1067
1083
  rb_define_private_method(cDS9Session, "make_callbacks", make_callbacks, 0);
1068
- rb_define_private_method(cDS9Client, "init_internals", client_init_internals, 1);
1069
- rb_define_private_method(cDS9Server, "init_internals", server_init_internals, 1);
1084
+ rb_define_private_method(cDS9Client, "init_internals", client_init_internals, 2);
1085
+ rb_define_private_method(cDS9Server, "init_internals", server_init_internals, 2);
1070
1086
 
1071
1087
  rb_define_method(cDS9Server, "submit_response", server_submit_response, 2);
1072
1088
  rb_define_method(cDS9Server, "submit_push_promise", server_submit_push_promise, 2);
@@ -1089,6 +1105,7 @@ void Init_ds9(void)
1089
1105
  id_on_data_chunk_recv = rb_intern("on_data_chunk_recv");
1090
1106
  id_before_frame_send = rb_intern("before_frame_send");
1091
1107
  id_on_data_source_read = rb_intern("on_data_source_read");
1108
+ id_eof_p = rb_intern("eof?");
1092
1109
  }
1093
1110
 
1094
1111
  /* vim: set noet sws=4 sw=4: */
data/ext/ds9/ds9.h CHANGED
@@ -4,6 +4,7 @@
4
4
  #include <ruby.h>
5
5
  #include <ruby/io.h>
6
6
  #include <nghttp2/nghttp2.h>
7
+ #include <ds9_option.h>
7
8
 
8
9
  static const rb_data_type_t ds9_session_type = {
9
10
  "DS9/session",
data/ext/ds9/ds9_frames.c CHANGED
@@ -45,7 +45,7 @@ VALUE WrapDS9FrameHeader(const nghttp2_frame_hd *hd)
45
45
  {
46
46
  VALUE klass = rb_const_get(cDS9FramesFrame, rb_intern("Header"));
47
47
  return rb_funcall(klass, rb_intern("new"), 4,
48
- INT2NUM(hd->length),
48
+ ULONG2NUM(hd->length),
49
49
  INT2NUM(hd->stream_id),
50
50
  INT2NUM(hd->type),
51
51
  INT2NUM(hd->flags));
@@ -127,7 +127,7 @@ static VALUE goaway_error_code(VALUE self)
127
127
  void Init_ds9_frames(VALUE mDS9)
128
128
  {
129
129
  mDS9Frames = rb_define_module_under(mDS9, "Frames");
130
- cDS9FramesFrame = rb_define_class_under(mDS9Frames, "Frame", rb_cData);
130
+ cDS9FramesFrame = rb_define_class_under(mDS9Frames, "Frame", rb_cObject);
131
131
 
132
132
  mDS9FramesFlags = rb_define_module_under(cDS9FramesFrame, "Flags");
133
133
 
@@ -0,0 +1,183 @@
1
+ #include <ds9_option.h>
2
+
3
+ VALUE cDS9Option;
4
+
5
+ static VALUE allocate_option(VALUE klass)
6
+ {
7
+ nghttp2_option *option;
8
+
9
+ nghttp2_option_new(&option);
10
+
11
+ return TypedData_Wrap_Struct(klass, &ds9_option_type, option);
12
+ }
13
+
14
+ static VALUE option_set_no_auto_ping_ack(VALUE self)
15
+ {
16
+ nghttp2_option *option;
17
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
18
+
19
+ nghttp2_option_set_no_auto_ping_ack(option, 1);
20
+
21
+ return self;
22
+ }
23
+
24
+ static VALUE option_set_no_auto_window_update(VALUE self)
25
+ {
26
+ nghttp2_option *option;
27
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
28
+
29
+ nghttp2_option_set_no_auto_window_update(option, 1);
30
+
31
+ return self;
32
+ }
33
+
34
+ static VALUE option_set_no_closed_streams(VALUE self)
35
+ {
36
+ nghttp2_option *option;
37
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
38
+
39
+ nghttp2_option_set_no_closed_streams(option, 1);
40
+
41
+ return self;
42
+ }
43
+
44
+ static VALUE option_set_no_http_messaging(VALUE self)
45
+ {
46
+ nghttp2_option *option;
47
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
48
+
49
+ nghttp2_option_set_no_http_messaging(option, 1);
50
+
51
+ return self;
52
+ }
53
+
54
+ static VALUE option_set_no_recv_client_magic(VALUE self)
55
+ {
56
+ nghttp2_option *option;
57
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
58
+
59
+ nghttp2_option_set_no_recv_client_magic(option, 1);
60
+
61
+ return self;
62
+ }
63
+
64
+
65
+ static VALUE option_set_builtin_recv_extension_type(VALUE self, VALUE size)
66
+ {
67
+ nghttp2_option *option;
68
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
69
+
70
+ nghttp2_option_set_builtin_recv_extension_type(option, NUM2INT(size));
71
+
72
+ return self;
73
+ }
74
+
75
+ static VALUE option_set_max_deflate_dynamic_table_size(VALUE self, VALUE size)
76
+ {
77
+ nghttp2_option *option;
78
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
79
+
80
+ nghttp2_option_set_max_deflate_dynamic_table_size(option, NUM2INT(size));
81
+
82
+ return self;
83
+ }
84
+
85
+ static VALUE option_set_max_send_header_block_length(VALUE self, VALUE size)
86
+ {
87
+ nghttp2_option *option;
88
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
89
+
90
+ nghttp2_option_set_max_send_header_block_length(option, NUM2INT(size));
91
+
92
+ return self;
93
+ }
94
+
95
+ static VALUE option_set_max_reserved_remote_streams(VALUE self, VALUE size)
96
+ {
97
+ nghttp2_option *option;
98
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
99
+
100
+ nghttp2_option_set_max_reserved_remote_streams(option, NUM2INT(size));
101
+
102
+ return self;
103
+ }
104
+
105
+ static VALUE option_set_peer_max_concurrent_streams(VALUE self, VALUE size)
106
+ {
107
+ nghttp2_option *option;
108
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
109
+
110
+ nghttp2_option_set_peer_max_concurrent_streams(option, NUM2INT(size));
111
+
112
+ return self;
113
+ }
114
+
115
+ static VALUE option_set_user_recv_extension_type(VALUE self, VALUE size)
116
+ {
117
+ nghttp2_option *option;
118
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
119
+
120
+ nghttp2_option_set_user_recv_extension_type(option, NUM2INT(size));
121
+
122
+ return self;
123
+ }
124
+
125
+ #if NGHTTP2_VERSION_NUM >= 0x012800 /* 1.40.0 */
126
+ static VALUE option_set_max_outbound_ack(VALUE self, VALUE size)
127
+ {
128
+ nghttp2_option *option;
129
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
130
+
131
+ nghttp2_option_set_max_outbound_ack(option, NUM2INT(size));
132
+
133
+ return self;
134
+ }
135
+ #endif
136
+
137
+ #if NGHTTP2_VERSION_NUM >= 0x012900 /* 1.41.0 */
138
+ static VALUE option_set_max_settings(VALUE self, VALUE size)
139
+ {
140
+ nghttp2_option *option;
141
+ TypedData_Get_Struct(self, nghttp2_option, &ds9_option_type, option);
142
+
143
+ nghttp2_option_set_max_settings(option, NUM2INT(size));
144
+
145
+ return self;
146
+ }
147
+ #endif
148
+
149
+ nghttp2_option* UnwrapDS9Option(VALUE opt)
150
+ {
151
+ nghttp2_option* option = NULL;
152
+
153
+ if (!NIL_P(opt)) {
154
+ TypedData_Get_Struct(opt, nghttp2_option, &ds9_option_type, option);
155
+ }
156
+
157
+ return option;
158
+ }
159
+
160
+ void Init_ds9_option(VALUE mDS9)
161
+ {
162
+ cDS9Option = rb_define_class_under(mDS9, "Option", rb_cObject);
163
+ rb_define_alloc_func(cDS9Option, allocate_option);
164
+
165
+ rb_define_method(cDS9Option, "set_no_auto_ping_ack", option_set_no_auto_ping_ack, 0);
166
+ rb_define_method(cDS9Option, "set_no_auto_window_update", option_set_no_auto_window_update, 0);
167
+ rb_define_method(cDS9Option, "set_no_closed_streams", option_set_no_closed_streams, 0);
168
+ rb_define_method(cDS9Option, "set_no_http_messaging", option_set_no_http_messaging, 0);
169
+ rb_define_method(cDS9Option, "set_no_recv_client_magic", option_set_no_recv_client_magic, 0);
170
+
171
+ rb_define_method(cDS9Option, "set_builtin_recv_extension_type", option_set_builtin_recv_extension_type, 1);
172
+ rb_define_method(cDS9Option, "set_max_deflate_dynamic_table_size", option_set_max_deflate_dynamic_table_size, 1);
173
+ rb_define_method(cDS9Option, "set_max_send_header_block_length", option_set_max_send_header_block_length, 1);
174
+ rb_define_method(cDS9Option, "set_max_reserved_remote_streams", option_set_max_reserved_remote_streams, 1);
175
+ rb_define_method(cDS9Option, "set_peer_max_concurrent_streams", option_set_peer_max_concurrent_streams, 1);
176
+ rb_define_method(cDS9Option, "set_user_recv_extension_type", option_set_user_recv_extension_type, 1);
177
+ #if NGHTTP2_VERSION_NUM >= 0x012800 /* 1.40.0 */
178
+ rb_define_method(cDS9Option, "set_max_outbound_ack", option_set_max_outbound_ack, 1);
179
+ #endif
180
+ #if NGHTTP2_VERSION_NUM >= 0x012900 /* 1.41.0 */
181
+ rb_define_method(cDS9Option, "set_max_settings", option_set_max_settings, 1);
182
+ #endif
183
+ }
@@ -0,0 +1,19 @@
1
+ #ifndef DS9_OPTION_H
2
+ #define DS9_OPTION_H
3
+
4
+ #include <ruby.h>
5
+ #include <nghttp2/nghttp2.h>
6
+
7
+ static const rb_data_type_t ds9_option_type = {
8
+ "DS9/option",
9
+ {0, (void (*)(void *))nghttp2_option_del, 0,},
10
+ 0, 0,
11
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
12
+ RUBY_TYPED_FREE_IMMEDIATELY,
13
+ #endif
14
+ };
15
+
16
+ void Init_ds9_option(VALUE mDS9);
17
+ nghttp2_option* UnwrapDS9Option(VALUE opt);
18
+
19
+ #endif
data/ext/ds9/extconf.rb CHANGED
@@ -4,6 +4,8 @@ def using_system_libraries?
4
4
  arg_config('--use-system-libraries', !!ENV['DS9_USE_SYSTEM_LIBRARIES'])
5
5
  end
6
6
 
7
+ dir_config('ds9')
8
+
7
9
  if using_system_libraries?
8
10
  if with_config("static")
9
11
  ldflags = pkg_config 'libnghttp2', 'libs-only-L'
@@ -21,20 +23,19 @@ else
21
23
  message "Building nghttp2\n"
22
24
  require 'rubygems'
23
25
  require 'mini_portile2'
24
- recipe = MiniPortile.new('nghttp2', 'v1.34.0')
25
- # We need to compile nghttp2 with `-fPIC` option, so delete `--disable-shared` from MiniPortile#configure_defaults
26
- recipe.configure_options = ['--enable-lib-only', '--enable-static', "--host=#{recipe.host}"]
26
+ recipe = MiniPortile.new('nghttp2', 'v1.43.0')
27
+ recipe.configure_options = recipe.configure_options + ['--with-pic', '--enable-lib-only']
27
28
 
28
29
  recipe.files << {
29
- url: 'https://github.com/nghttp2/nghttp2/releases/download/v1.34.0/nghttp2-1.34.0.tar.gz',
30
- sha1: '2d0ad93a254a7a6e6c737f2fd2e10e4810a41f74',
30
+ url: 'https://github.com/nghttp2/nghttp2/releases/download/v1.43.0/nghttp2-1.43.0.tar.gz',
31
+ sha1: '8686c8ceee769de8b9e304739b223981df9df104',
31
32
  }
32
33
  recipe.cook
33
34
 
34
35
  # `recipe.activate` uses invalid path for this package.
35
36
  $LIBPATH = ["#{recipe.path}/lib"] + $LIBPATH
36
37
  $CPPFLAGS << " -I#{recipe.path}/include"
37
- $LIBS << " -lnghttp2 -lstdc++"
38
+ $LIBS << " -lstdc++"
38
39
  end
39
40
 
40
41
  abort 'nghttp2/nghttp2.h not found' unless have_header('nghttp2/nghttp2.h')
data/lib/ds9.rb CHANGED
@@ -75,10 +75,11 @@ module DS9
75
75
  end
76
76
 
77
77
  class Session
78
- def initialize
78
+ # @param option [DS9::Option]
79
+ def initialize(option: nil)
79
80
  @post_buffers = {}
80
81
  cbs = make_callbacks
81
- init_internals cbs
82
+ init_internals(cbs, option)
82
83
  end
83
84
 
84
85
  private
data/lib/ds9/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DS9
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.2'
3
3
  end
data/test/helper.rb CHANGED
@@ -12,7 +12,7 @@ trap("INFO") {
12
12
  puts k.backtrace
13
13
  puts "#" * 90
14
14
  end
15
- }
15
+ } if Signal.list.key?("INFO")
16
16
 
17
17
  module DS9
18
18
  class TestCase < Minitest::Test
@@ -0,0 +1,107 @@
1
+ require 'helper'
2
+
3
+ class TestMeme < Minitest::Test
4
+ def setup
5
+ @option = DS9::Option.new
6
+ end
7
+
8
+ def test_set_no_auto_ping_ack
9
+ assert @option.set_no_auto_ping_ack
10
+ end
11
+
12
+ def test_set_no_auto_window_update
13
+ assert @option.set_no_auto_window_update
14
+ end
15
+
16
+ def test_set_no_closed_streams
17
+ assert @option.set_no_closed_streams
18
+ end
19
+
20
+ def test_set_no_http_messaging
21
+ assert @option.set_no_http_messaging
22
+ end
23
+
24
+ def test_set_no_recv_client_magic
25
+ assert @option.set_no_recv_client_magic
26
+ end
27
+
28
+ def test_set_builtin_recv_extension_type
29
+ assert @option.set_builtin_recv_extension_type(1)
30
+ end
31
+
32
+ def test_set_builtin_recv_extension_type_with_not_num
33
+ assert_raises TypeError do
34
+ assert @option.set_builtin_recv_extension_type('invalid')
35
+ end
36
+ end
37
+
38
+ def test_set_max_deflate_dynamic_table_size
39
+ assert @option.set_max_deflate_dynamic_table_size(1)
40
+ end
41
+
42
+ def test_set_max_deflate_dynamic_table_size_with_not_num
43
+ assert_raises TypeError do
44
+ @option.set_max_deflate_dynamic_table_size('invalid')
45
+ end
46
+ end
47
+
48
+ def test_set_max_send_header_block_length
49
+ assert @option.set_max_send_header_block_length(1)
50
+ end
51
+
52
+ def test_set_max_send_header_block_length_with_not_num
53
+ assert_raises TypeError do
54
+ assert @option.set_max_send_header_block_length('invalid')
55
+ end
56
+ end
57
+
58
+ def test_set_max_reserved_remote_streams
59
+ assert @option.set_max_reserved_remote_streams(100)
60
+ end
61
+
62
+ def test_set_max_reserved_remote_streams_not_num
63
+ assert_raises TypeError do
64
+ @option.set_max_reserved_remote_streams('invalid')
65
+ end
66
+ end
67
+
68
+ def test_set_peer_max_concurrent_streams
69
+ assert @option.set_peer_max_concurrent_streams(1)
70
+ end
71
+
72
+ def test_set_peer_max_concurrent_stream_with_not_num
73
+ assert_raises TypeError do
74
+ assert @option.set_peer_max_concurrent_streams('invalid')
75
+ end
76
+ end
77
+
78
+ def test_set_user_recv_extension_type
79
+ assert @option.set_user_recv_extension_type(1)
80
+ end
81
+
82
+ def test_set_user_recv_extension_type_with_not_num
83
+ assert_raises TypeError do
84
+ assert @option.set_user_recv_extension_type('invalid')
85
+ end
86
+ end
87
+
88
+ def test_set_max_outbound_ack
89
+ assert @option.set_max_outbound_ack(100)
90
+ end
91
+
92
+ def test_set_max_outbound_ack_with_not_num
93
+ assert_raises TypeError do
94
+ assert @option.set_max_outbound_ack('invalid')
95
+ end
96
+ end
97
+
98
+ def test_set_max_settings
99
+ assert @option.set_max_settings(16)
100
+ end
101
+
102
+ def test_set_max_settings_with_not_num
103
+ assert_raises TypeError do
104
+ assert @option.set_max_settings('invalid')
105
+ end
106
+ end
107
+ end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ds9
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  - Yuta Iwama
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2015-07-06 00:00:00.000000000 Z
@@ -95,6 +95,7 @@ extra_rdoc_files:
95
95
  - README.md
96
96
  files:
97
97
  - ".autotest"
98
+ - ".github/workflows/ruby.yml"
98
99
  - ".gitignore"
99
100
  - CHANGELOG.md
100
101
  - Gemfile
@@ -104,18 +105,21 @@ files:
104
105
  - ext/ds9/ds9.c
105
106
  - ext/ds9/ds9.h
106
107
  - ext/ds9/ds9_frames.c
108
+ - ext/ds9/ds9_option.c
109
+ - ext/ds9/ds9_option.h
107
110
  - ext/ds9/extconf.rb
108
111
  - lib/ds9.rb
109
112
  - lib/ds9/version.rb
110
113
  - test/helper.rb
111
114
  - test/test_client.rb
112
115
  - test/test_ds9.rb
116
+ - test/test_ds9_option.rb
113
117
  - test/test_server.rb
114
118
  homepage: https://github.com/tenderlove/ds9
115
119
  licenses:
116
120
  - MIT
117
121
  metadata: {}
118
- post_install_message:
122
+ post_install_message:
119
123
  rdoc_options:
120
124
  - "--main"
121
125
  - README.md
@@ -132,9 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
136
  - !ruby/object:Gem::Version
133
137
  version: '0'
134
138
  requirements: []
135
- rubyforge_project:
136
- rubygems_version: 2.6.14.1
137
- signing_key:
139
+ rubygems_version: 3.2.14
140
+ signing_key:
138
141
  specification_version: 4
139
142
  summary: This library allows you to write HTTP/2 clients and servers
140
143
  test_files: []