ds9 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/ds9/ds9.c +58 -5
- data/lib/ds9.rb +1 -1
- data/test/helper.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c4e36345289f23d14f435bc4cb397a72a5bda5d
|
4
|
+
data.tar.gz: 142a14a755b07d0ea718f3de691fb87fed448ed3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52385947712d95677a593d18a16e81bbe9332042854537fcc4734fb8e5f39fb15e65380349725abe5d5ebedc9f3c6b97da573ffd18a10cc4b260924aac30551d
|
7
|
+
data.tar.gz: fcf9414805469006684c1ecd1a30297322892baa0e3d04804688aba6949a90b77ea0eecf99981f0ca3ae18315b6399947e75d74d649de49dd668c50e746d8ce6
|
data/ext/ds9/ds9.c
CHANGED
@@ -283,6 +283,13 @@ static ssize_t rb_data_read_callback(nghttp2_session *session,
|
|
283
283
|
return 0;
|
284
284
|
}
|
285
285
|
|
286
|
+
if (FIXNUM_P(ret)) {
|
287
|
+
ssize_t err = NUM2INT(ret);
|
288
|
+
if (err == NGHTTP2_ERR_DEFERRED) {
|
289
|
+
return err;
|
290
|
+
}
|
291
|
+
}
|
292
|
+
|
286
293
|
Check_Type(ret, T_STRING);
|
287
294
|
len = RSTRING_LEN(ret);
|
288
295
|
memcpy(buf, StringValuePtr(ret), len);
|
@@ -588,12 +595,16 @@ ruby_read(nghttp2_session *session, int32_t stream_id, uint8_t *buf, size_t leng
|
|
588
595
|
rb_funcall(self, rb_intern("remove_post_buffer"), 1, INT2NUM(stream_id));
|
589
596
|
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
|
590
597
|
return 0;
|
591
|
-
} else if (ret
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
598
|
+
} else if (FIXNUM_P(ret)) {
|
599
|
+
ssize_t err = NUM2INT(ret);
|
600
|
+
if (err == NGHTTP2_ERR_DEFERRED) {
|
601
|
+
return err;
|
602
|
+
}
|
596
603
|
}
|
604
|
+
|
605
|
+
Check_Type(ret, T_STRING);
|
606
|
+
memcpy(buf, RSTRING_PTR(ret), RSTRING_LEN(ret));
|
607
|
+
return RSTRING_LEN(ret);
|
597
608
|
}
|
598
609
|
|
599
610
|
static ssize_t
|
@@ -854,6 +865,46 @@ static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
|
|
854
865
|
return self;
|
855
866
|
}
|
856
867
|
|
868
|
+
static VALUE server_submit_headers(VALUE self, VALUE stream_id, VALUE headers) {
|
869
|
+
nghttp2_session *session;
|
870
|
+
size_t niv;
|
871
|
+
nghttp2_nv *nva, *head;
|
872
|
+
int rv;
|
873
|
+
copy_header_func_t copy_func;
|
874
|
+
|
875
|
+
TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
|
876
|
+
CheckSelf(session);
|
877
|
+
|
878
|
+
switch(TYPE(headers))
|
879
|
+
{
|
880
|
+
case T_ARRAY:
|
881
|
+
niv = RARRAY_LEN(headers);
|
882
|
+
copy_func = copy_list_to_nv;
|
883
|
+
break;
|
884
|
+
case T_HASH:
|
885
|
+
niv = RHASH_SIZE(headers);
|
886
|
+
copy_func = copy_hash_to_nv;
|
887
|
+
break;
|
888
|
+
default:
|
889
|
+
Check_Type(headers, T_ARRAY);
|
890
|
+
}
|
891
|
+
|
892
|
+
nva = xcalloc(niv, sizeof(nghttp2_nv));
|
893
|
+
|
894
|
+
copy_func(headers, nva, niv);
|
895
|
+
|
896
|
+
/* nghttp2_submit_headers is too low level API for ds9 */
|
897
|
+
rv = nghttp2_submit_response(session, NUM2INT(stream_id), nva, niv, NULL);
|
898
|
+
|
899
|
+
xfree(nva);
|
900
|
+
|
901
|
+
if (0 != rv) {
|
902
|
+
explode(rv);
|
903
|
+
}
|
904
|
+
|
905
|
+
return self;
|
906
|
+
}
|
907
|
+
|
857
908
|
static VALUE make_callbacks(VALUE self)
|
858
909
|
{
|
859
910
|
nghttp2_session_callbacks *callbacks;
|
@@ -975,6 +1026,7 @@ void Init_ds9(void)
|
|
975
1026
|
|
976
1027
|
rb_define_const(mDS9, "ERR_WOULDBLOCK", INT2NUM(NGHTTP2_ERR_WOULDBLOCK));
|
977
1028
|
rb_define_const(mDS9, "ERR_EOF", INT2NUM(NGHTTP2_ERR_EOF));
|
1029
|
+
rb_define_const(mDS9, "ERR_DEFERRED", INT2NUM(NGHTTP2_ERR_DEFERRED));
|
978
1030
|
rb_define_const(mDS9, "NO_ERROR", INT2NUM(NGHTTP2_NO_ERROR));
|
979
1031
|
rb_define_const(mDS9, "DEFAULT_WEIGHT", INT2NUM(NGHTTP2_DEFAULT_WEIGHT));
|
980
1032
|
rb_define_const(mDS9, "MAX_WEIGHT", INT2NUM(NGHTTP2_MAX_WEIGHT));
|
@@ -1020,6 +1072,7 @@ void Init_ds9(void)
|
|
1020
1072
|
rb_define_method(cDS9Server, "submit_push_promise", server_submit_push_promise, 2);
|
1021
1073
|
rb_define_method(cDS9Server, "submit_shutdown", session_submit_shutdown, 0);
|
1022
1074
|
rb_define_method(cDS9Server, "submit_trailer", session_submit_trailer, 2);
|
1075
|
+
rb_define_method(cDS9Server, "submit_headers", server_submit_headers, 2);
|
1023
1076
|
|
1024
1077
|
rb_define_singleton_method(eDS9Exception, "to_string", errors_to_string, 1);
|
1025
1078
|
|
data/lib/ds9.rb
CHANGED
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ds9
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.6.14
|
123
|
+
rubygems_version: 2.6.14.1
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: This library allows you to write HTTP/2 clients and servers
|