Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
6bcdb178
Commit
6bcdb178
authored
Nov 03, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Header key and value must be string in mruby script
parent
5e10cc4c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
src/shrpx_mruby_module_request.cc
src/shrpx_mruby_module_request.cc
+9
-3
src/shrpx_mruby_module_response.cc
src/shrpx_mruby_module_response.cc
+9
-3
No files found.
src/shrpx_mruby_module_request.cc
View file @
6bcdb178
...
...
@@ -218,7 +218,7 @@ mrb_value request_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
check_phase
(
mrb
,
data
->
phase
,
PHASE_REQUEST
);
mrb_value
key
,
values
;
mrb_get_args
(
mrb
,
"
o
o"
,
&
key
,
&
values
);
mrb_get_args
(
mrb
,
"
S
o"
,
&
key
,
&
values
);
if
(
RSTRING_LEN
(
key
)
==
0
)
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"empty key is not allowed"
);
...
...
@@ -251,10 +251,14 @@ mrb_value request_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
headers
.
resize
(
p
);
}
if
(
mrb_
obj_is_instance_of
(
mrb
,
values
,
mrb
->
array_clas
s
))
{
if
(
mrb_
array_p
(
value
s
))
{
auto
n
=
mrb_ary_len
(
mrb
,
values
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
auto
value
=
mrb_ary_ref
(
mrb
,
values
,
i
);
if
(
!
mrb_string_p
(
value
))
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"value must be string"
);
}
req
.
fs
.
add_header_token
(
keyref
,
make_string_ref
(
balloc
,
...
...
@@ -262,13 +266,15 @@ mrb_value request_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
static_cast
<
size_t
>
(
RSTRING_LEN
(
value
))}),
false
,
token
);
}
}
else
if
(
!
mrb_nil
_p
(
values
))
{
}
else
if
(
mrb_string
_p
(
values
))
{
req
.
fs
.
add_header_token
(
keyref
,
make_string_ref
(
balloc
,
StringRef
{
RSTRING_PTR
(
values
),
static_cast
<
size_t
>
(
RSTRING_LEN
(
values
))}),
false
,
token
);
}
else
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"value must be string"
);
}
return
mrb_nil_value
();
...
...
src/shrpx_mruby_module_response.cc
View file @
6bcdb178
...
...
@@ -110,7 +110,7 @@ mrb_value response_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
auto
&
balloc
=
downstream
->
get_block_allocator
();
mrb_value
key
,
values
;
mrb_get_args
(
mrb
,
"
o
o"
,
&
key
,
&
values
);
mrb_get_args
(
mrb
,
"
S
o"
,
&
key
,
&
values
);
if
(
RSTRING_LEN
(
key
)
==
0
)
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"empty key is not allowed"
);
...
...
@@ -143,10 +143,14 @@ mrb_value response_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
headers
.
resize
(
p
);
}
if
(
mrb_
obj_is_instance_of
(
mrb
,
values
,
mrb
->
array_clas
s
))
{
if
(
mrb_
array_p
(
value
s
))
{
auto
n
=
mrb_ary_len
(
mrb
,
values
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
auto
value
=
mrb_ary_ref
(
mrb
,
values
,
i
);
if
(
!
mrb_string_p
(
value
))
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"value must be string"
);
}
resp
.
fs
.
add_header_token
(
keyref
,
make_string_ref
(
balloc
,
...
...
@@ -154,13 +158,15 @@ mrb_value response_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
static_cast
<
size_t
>
(
RSTRING_LEN
(
value
))}),
false
,
token
);
}
}
else
if
(
!
mrb_nil
_p
(
values
))
{
}
else
if
(
mrb_string
_p
(
values
))
{
resp
.
fs
.
add_header_token
(
keyref
,
make_string_ref
(
balloc
,
StringRef
{
RSTRING_PTR
(
values
),
static_cast
<
size_t
>
(
RSTRING_LEN
(
values
))}),
false
,
token
);
}
else
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"value must be string"
);
}
return
mrb_nil_value
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment