Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
ec6296e4
Commit
ec6296e4
authored
Jun 22, 2017
by
Simon Désaulniers
Committed by
Adrien Béraud
Jun 27, 2017
Browse files
Options
Downloads
Patches
Plain Diff
http_server: enable WHERE filtering for GET method
parent
b96d0de8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/tools/http_server.py
+7
-4
7 additions, 4 deletions
python/tools/http_server.py
with
7 additions
and
4 deletions
python/tools/http_server.py
+
7
−
4
View file @
ec6296e4
...
@@ -32,10 +32,13 @@ class DhtServer(resource.Resource):
...
@@ -32,10 +32,13 @@ class DhtServer(resource.Resource):
self
.
node
.
bootstrap
(
b_url
.
hostname
,
str
(
b_url
.
port
)
if
b_url
.
port
else
'
4222
'
)
self
.
node
.
bootstrap
(
b_url
.
hostname
,
str
(
b_url
.
port
)
if
b_url
.
port
else
'
4222
'
)
def
render_GET
(
self
,
req
):
def
render_GET
(
self
,
req
):
uri
=
req
.
uri
[
1
:]
uri
=
req
.
uri
[
1
:].
decode
().
rsplit
(
'
?
'
,
1
)[
0
]
h
=
dht
.
InfoHash
(
uri
)
if
len
(
uri
)
==
40
else
dht
.
InfoHash
.
get
(
uri
.
decode
())
h
=
dht
.
InfoHash
(
uri
.
encode
())
if
len
(
uri
)
==
40
else
dht
.
InfoHash
.
get
(
uri
)
print
(
'
GET
'
,
'"'
+
uri
.
decode
()
+
'"'
,
h
)
w
=
dht
.
Where
(
'
WHERE
'
+
''
.
join
(
k
.
decode
()
+
'
=
'
+
req
.
args
[
k
][
0
].
decode
()
+
'
,
'
res
=
self
.
node
.
get
(
h
)
for
k
in
req
.
args
.
keys
()
if
k
in
[
b
'
id
'
,
b
'
user_type
'
,
b
'
value_type
'
,
b
'
owner
'
,
b
'
seq
'
])[:
-
1
])
print
(
'
GET
'
,
'"'
+
uri
+
'"'
,
h
,
w
)
res
=
self
.
node
.
get
(
h
,
where
=
w
)
req
.
setHeader
(
b
"
content-type
"
,
b
"
application/json
"
)
req
.
setHeader
(
b
"
content-type
"
,
b
"
application/json
"
)
return
json
.
dumps
({
'
{:x}
'
.
format
(
v
.
id
):{
'
base64
'
:
base64
.
b64encode
(
v
.
data
).
decode
()}
for
v
in
res
}).
encode
()
return
json
.
dumps
({
'
{:x}
'
.
format
(
v
.
id
):{
'
base64
'
:
base64
.
b64encode
(
v
.
data
).
decode
()}
for
v
in
res
}).
encode
()
...
...
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