Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
5efc2242
Commit
5efc2242
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
namedirectory: use full url for requests
Change-Id: I09a2c206d35c30c998f2f7978f98c466c0ba3921
parent
6fd754dc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/jamidht/namedirectory.cpp
+7
-16
7 additions, 16 deletions
src/jamidht/namedirectory.cpp
with
7 additions
and
16 deletions
src/jamidht/namedirectory.cpp
+
7
−
16
View file @
5efc2242
...
...
@@ -135,16 +135,12 @@ NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb)
cb
(
cacheResult
,
Response
::
found
);
return
;
}
auto
request
=
std
::
make_shared
<
Request
>
(
*
httpContext_
,
resolver_
,
QUERY_ADDR
+
addr
);
auto
request
=
std
::
make_shared
<
Request
>
(
*
httpContext_
,
resolver_
,
serverUrl_
+
QUERY_ADDR
+
addr
);
auto
reqid
=
request
->
id
();
try
{
request
->
set_connection_type
(
restinio
::
http_connection_header_t
::
keep_alive
);
request
->
set_method
(
restinio
::
http_method_get
());
setHeaderFields
(
*
request
);
request
->
add_on_state_change_callback
([
this
,
cb
=
std
::
move
(
cb
),
reqid
,
addr
]
(
Request
::
State
state
,
const
dht
::
http
::
Response
&
response
){
if
(
state
!=
Request
::
State
::
DONE
)
return
;
request
->
add_on_done_callback
([
this
,
cb
=
std
::
move
(
cb
),
reqid
,
addr
]
(
const
dht
::
http
::
Response
&
response
){
if
(
response
.
status_code
>=
400
&&
response
.
status_code
<
500
){
cb
(
""
,
Response
::
notFound
);
}
...
...
@@ -213,15 +209,13 @@ NameDirectory::lookupName(const std::string& n, LookupCallback cb)
cb
(
cacheResult
,
Response
::
found
);
return
;
}
auto
request
=
std
::
make_shared
<
Request
>
(
*
httpContext_
,
resolver_
,
QUERY_NAME
+
name
);
auto
request
=
std
::
make_shared
<
Request
>
(
*
httpContext_
,
resolver_
,
serverUrl_
+
QUERY_NAME
+
name
);
auto
reqid
=
request
->
id
();
try
{
request
->
set_method
(
restinio
::
http_method_get
());
setHeaderFields
(
*
request
);
request
->
add_on_state_change_callback
([
this
,
reqid
,
name
,
cb
=
std
::
move
(
cb
)]
(
Request
::
State
state
,
const
dht
::
http
::
Response
&
response
){
if
(
state
!=
Request
::
State
::
DONE
)
return
;
request
->
add_on_done_callback
([
this
,
reqid
,
name
,
cb
=
std
::
move
(
cb
)]
(
const
dht
::
http
::
Response
&
response
){
if
(
response
.
status_code
>=
400
&&
response
.
status_code
<
500
)
cb
(
""
,
Response
::
notFound
);
else
if
(
response
.
status_code
<
200
||
response
.
status_code
>
299
)
...
...
@@ -321,7 +315,7 @@ void NameDirectory::registerName(const std::string& addr, const std::string& n,
jami
::
Blob
(
publickey
.
begin
(),
publickey
.
end
()))
<<
"
\"
}"
;
body
=
ss
.
str
();
}
auto
request
=
std
::
make_shared
<
Request
>
(
*
httpContext_
,
resolver_
,
QUERY_NAME
+
name
);
auto
request
=
std
::
make_shared
<
Request
>
(
*
httpContext_
,
resolver_
,
serverUrl_
+
QUERY_NAME
+
name
);
auto
reqid
=
request
->
id
();
try
{
request
->
set_method
(
restinio
::
http_method_post
());
...
...
@@ -330,10 +324,7 @@ void NameDirectory::registerName(const std::string& addr, const std::string& n,
JAMI_WARN
(
"RegisterName: sending request %s %s"
,
addr
.
c_str
(),
name
.
c_str
());
request
->
add_on_state_change_callback
([
this
,
reqid
,
name
,
addr
,
cb
=
std
::
move
(
cb
)]
(
Request
::
State
state
,
const
dht
::
http
::
Response
&
response
){
if
(
state
!=
Request
::
State
::
DONE
)
return
;
request
->
add_on_done_callback
([
this
,
reqid
,
name
,
addr
,
cb
=
std
::
move
(
cb
)](
const
dht
::
http
::
Response
&
response
){
if
(
response
.
status_code
==
400
){
cb
(
RegistrationResponse
::
incompleteRequest
);
JAMI_ERR
(
"RegistrationResponse::incompleteRequest"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment