Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
recurls
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
Łukasz Nowak
recurls
Commits
2d4b1f65
Commit
2d4b1f65
authored
Dec 13, 2024
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recurls: Use file to pass the data
Passing binary data via argument is dangrous.
parent
080f2313
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
src/recurls/recurls.py
src/recurls/recurls.py
+9
-1
No files found.
src/recurls/recurls.py
View file @
2d4b1f65
...
...
@@ -64,6 +64,7 @@ class Recurls(object):
response_header_file
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
).
name
response_file
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
).
name
hsts_file
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
).
name
data_file
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
).
name
command_list
=
[
self
.
curl
,
'--disable'
,
...
...
@@ -78,7 +79,11 @@ class Recurls(object):
'--write-out'
,
'%{json}'
]
if
data
is
not
None
:
command_list
.
extend
([
'--data-binary'
,
data
])
with
open
(
data_file
,
'wb'
)
as
fh
:
if
getattr
(
data
,
'encode'
,
None
)
is
not
None
:
data
=
data
.
encode
()
fh
.
write
(
data
)
command_list
.
extend
([
'--data-binary'
,
'@'
+
data_file
])
if
certificate
is
not
None
:
command_list
.
extend
([
'--cert'
,
certificate
])
if
allow_redirects
:
...
...
@@ -146,6 +151,8 @@ class Recurls(object):
header
,
value
=
line
.
split
(
':'
,
1
)
value
=
value
.
strip
()
response
.
headers
.
add_header
(
header
,
value
)
with
open
(
response_file
,
'rb'
)
as
fh
:
response
.
raw_bytes
=
fh
.
read
()
if
response
.
headers
.
get
(
'content-encoding'
)
==
'gzip'
:
with
gzip
.
GzipFile
(
response_file
)
as
fh
:
response
.
text
=
fh
.
read
().
decode
()
...
...
@@ -202,6 +209,7 @@ class Recurls(object):
os
.
unlink
(
request_header_file
)
os
.
unlink
(
response_file
)
os
.
unlink
(
hsts_file
)
os
.
unlink
(
data_file
)
# kwargs:
# params - Dictionary, list of tuples or bytes to send in the query
# string for the Request.
...
...
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