Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.cpp
/
Microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
89ee2b31
authored
Jun 26, 2018
by
Amir Aharon
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add headers to evpp implementation
parent
4494ebbc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
src/utils/EvppRequest.cpp
src/utils/EvppRequest.h
src/utils/EvppRequest.cpp
View file @
89ee2b31
...
...
@@ -91,6 +91,15 @@ void EvppRequest::ExecuteInLoop() {
goto
failed
;
}
/**
* add custom headers
*/
if
(
!
headers_map_
.
empty
()){
for
(
auto
entry
:
headers_map_
){
evhttp_add_header
(
req
->
output_headers
,
entry
.
first
.
c_str
(),
entry
.
second
.
c_str
());
}
}
if
(
!
body_
.
empty
())
{
//req_type = EVHTTP_REQ_POST;
if
(
evbuffer_add
(
req
->
output_buffer
,
body_
.
c_str
(),
body_
.
size
()))
{
...
...
src/utils/EvppRequest.h
View file @
89ee2b31
...
...
@@ -56,6 +56,13 @@ public:
void
set_retry_interval
(
Duration
d
)
{
retry_interval_
=
d
;
}
void
add_header
(
const
std
::
string
&
header
,
const
std
::
string
&
value
){
headers_map_
[
header
]
=
value
;
}
void
add_headers
(
std
::
map
<
std
::
string
,
std
::
string
>&
headers_map
){
headers_map_
.
insert
(
headers_map
.
begin
(),
headers_map
.
end
());
}
private
:
static
void
HandleResponse
(
struct
evhttp_request
*
r
,
void
*
v
);
void
HandleResponse
(
struct
evhttp_request
*
r
);
...
...
@@ -72,6 +79,7 @@ private:
std
::
shared_ptr
<
Conn
>
conn_
;
EvppHandler
handler_
;
evhttp_cmd_type
req_type_
;
std
::
map
<
std
::
string
,
std
::
string
>
headers_map_
;
// The retried times
int
retried_
=
0
;
...
...
@@ -88,6 +96,9 @@ typedef std::shared_ptr<EvppRequest> EvppRequestPtr;
class
GetEvppRequest
:
public
EvppRequest
{
public
:
GetEvppRequest
(
EventLoop
*
loop
,
const
std
::
string
&
url
,
const
std
::
string
&
body
,
Duration
timeout
)
:
EvppRequest
(
loop
,
EVHTTP_REQ_GET
,
url
,
body
,
timeout
)
{}
GetEvppRequest
(
ConnPool
*
pool
,
EventLoop
*
loop
,
const
std
::
string
&
uri_with_param
)
:
EvppRequest
(
pool
,
loop
,
EVHTTP_REQ_GET
,
uri_with_param
,
empty_
)
{}
...
...
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