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
05a761b6
Commit
05a761b6
authored
Sep 03, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add Request.remote_addr which returns client remote address
parent
14f5240d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
src/shrpx_mruby_module_request.cc
src/shrpx_mruby_module_request.cc
+17
-0
No files found.
src/shrpx_mruby_module_request.cc
View file @
05a761b6
...
@@ -30,6 +30,8 @@
...
@@ -30,6 +30,8 @@
#include <mruby/array.h>
#include <mruby/array.h>
#include "shrpx_downstream.h"
#include "shrpx_downstream.h"
#include "shrpx_upstream.h"
#include "shrpx_client_handler.h"
#include "shrpx_mruby.h"
#include "shrpx_mruby.h"
#include "shrpx_mruby_module.h"
#include "shrpx_mruby_module.h"
#include "util.h"
#include "util.h"
...
@@ -226,6 +228,19 @@ mrb_value request_set_header(mrb_state *mrb, mrb_value self) {
...
@@ -226,6 +228,19 @@ mrb_value request_set_header(mrb_state *mrb, mrb_value self) {
}
}
}
// namespace
}
// namespace
namespace
{
mrb_value
request_get_remote_addr
(
mrb_state
*
mrb
,
mrb_value
self
)
{
auto
data
=
static_cast
<
MRubyAssocData
*>
(
mrb
->
ud
);
auto
downstream
=
data
->
downstream
;
auto
upstream
=
downstream
->
get_upstream
();
auto
handler
=
upstream
->
get_client_handler
();
auto
&
ipaddr
=
handler
->
get_ipaddr
();
return
mrb_str_new
(
mrb
,
ipaddr
.
c_str
(),
ipaddr
.
size
());
}
}
// namespace
void
init_request_class
(
mrb_state
*
mrb
,
RClass
*
module
)
{
void
init_request_class
(
mrb_state
*
mrb
,
RClass
*
module
)
{
auto
request_class
=
auto
request_class
=
mrb_define_class_under
(
mrb
,
module
,
"Request"
,
mrb
->
object_class
);
mrb_define_class_under
(
mrb
,
module
,
"Request"
,
mrb
->
object_class
);
...
@@ -256,6 +271,8 @@ void init_request_class(mrb_state *mrb, RClass *module) {
...
@@ -256,6 +271,8 @@ void init_request_class(mrb_state *mrb, RClass *module) {
MRB_ARGS_NONE
());
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
request_class
,
"set_header"
,
request_set_header
,
mrb_define_method
(
mrb
,
request_class
,
"set_header"
,
request_set_header
,
MRB_ARGS_REQ
(
2
));
MRB_ARGS_REQ
(
2
));
mrb_define_method
(
mrb
,
request_class
,
"remote_addr"
,
request_get_remote_addr
,
MRB_ARGS_NONE
());
}
}
}
// namespace mruby
}
// namespace mruby
...
...
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