Class: DS9::Server
Instance Method Summary
collapse
Methods inherited from Session
#initialize, #mem_receive, #mem_send, #outbound_queue_size, #receive, #send, #stream_local_closed?, #stream_remote_closed?, #submit_goaway, #submit_ping, #submit_settings, #terminate_session, #want_read?, #want_write?
Constructor Details
This class inherits a constructor from DS9::Session
Instance Method Details
#submit_push_promise(stream_id, headers) ⇒ Object
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
# File 'ext/ds9/ds9.c', line 868
static VALUE server_submit_push_promise(VALUE self, VALUE stream_id, VALUE headers)
{
nghttp2_session *session;
nghttp2_nv *nva, *head;
size_t niv, i;
int rv;
TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
CheckSelf(session);
Check_Type(headers, T_ARRAY);
niv = RARRAY_LEN(headers);
nva = xcalloc(niv, sizeof(nghttp2_nv));
head = nva;
for(i = 0; i < niv; i++, head++) {
VALUE tuple = rb_ary_entry(headers, (long)i);
VALUE name = rb_ary_entry(tuple, 0);
VALUE value = rb_ary_entry(tuple, 1);
head->name = (uint8_t *)StringValuePtr(name);
head->namelen = RSTRING_LEN(name);
head->value = (uint8_t *)StringValuePtr(value);
head->valuelen = RSTRING_LEN(value);
head->flags = NGHTTP2_NV_FLAG_NONE;
}
rv = nghttp2_submit_push_promise(session, 0, NUM2INT(stream_id), nva, niv, NULL);
xfree(nva);
switch(rv) {
case NGHTTP2_ERR_NOMEM:
case NGHTTP2_ERR_PROTO:
case NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE:
case NGHTTP2_ERR_INVALID_ARGUMENT:
return explode(rv);
break;
default:
return INT2NUM(rv);
}
}
|
#submit_response(stream_id, headers) ⇒ Object
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
|
# File 'ext/ds9/ds9.c', line 781
static VALUE server_submit_response(VALUE self, VALUE stream_id, VALUE headers)
{
nghttp2_session *session;
size_t niv;
nghttp2_nv *nva, *head;
nghttp2_data_provider provider;
int rv;
copy_header_func_t copy_func;
TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
CheckSelf(session);
switch(TYPE(headers))
{
case T_ARRAY:
niv = RARRAY_LEN(headers);
copy_func = copy_list_to_nv;
break;
case T_HASH:
niv = RHASH_SIZE(headers);
copy_func = copy_hash_to_nv;
break;
default:
Check_Type(headers, T_ARRAY);
}
nva = xcalloc(niv, sizeof(nghttp2_nv));
copy_func(headers, nva, niv);
provider.read_callback = rb_data_read_callback;
rv = nghttp2_submit_response(session, NUM2INT(stream_id), nva, niv, &provider);
xfree(nva);
if (0 != rv) {
explode(rv);
}
return self;
}
|
#submit_shutdown ⇒ Object
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
|
# File 'ext/ds9/ds9.c', line 681
static VALUE session_submit_shutdown(VALUE self)
{
int rv;
nghttp2_session *session;
TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
CheckSelf(session);
rv = nghttp2_submit_shutdown_notice(session);
if (rv == 0)
return Qtrue;
return explode(rv);
}
|
#submit_trailer(stream_id, trailers) ⇒ Object
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
# File 'ext/ds9/ds9.c', line 457
static VALUE session_submit_trailer(VALUE self, VALUE stream_id, VALUE trailers)
{
size_t niv;
nghttp2_nv *nva;
nghttp2_session *session;
int rv;
int32_t s_id;
copy_header_func_t copy_func;
TypedData_Get_Struct(self, nghttp2_session, &ds9_session_type, session);
CheckSelf(session);
s_id = NUM2INT(stream_id);
switch(TYPE(trailers))
{
case T_ARRAY:
niv = RARRAY_LEN(trailers);
copy_func = copy_list_to_nv;
break;
case T_HASH:
niv = RHASH_SIZE(trailers);
copy_func = copy_hash_to_nv;
break;
default:
Check_Type(trailers, T_ARRAY);
}
nva = xcalloc(niv, sizeof(nghttp2_nv));
copy_func(trailers, nva, niv);
rv = nghttp2_submit_trailer(session, s_id, nva, niv);
xfree(nva);
if (0 != rv) {
explode(rv);
}
return self;
}
|