Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
73f58c57
Commit
73f58c57
authored
Feb 06, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/curl: use CURLOPT_POSTFIELDS instead of CURLOPT_READFUNCTION
parent
43348a3e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
43 deletions
+8
-43
CurlStorage.cxx
src/storage/plugins/CurlStorage.cxx
+8
-43
No files found.
src/storage/plugins/CurlStorage.cxx
View file @
73f58c57
...
...
@@ -151,41 +151,6 @@ private:
};
/**
* A helper class which feeds a (foreign) memory buffer into the
* CURLOPT_READFUNCTION.
*/
class
CurlRequestBody
{
ConstBuffer
<
char
>
data
;
public
:
explicit
CurlRequestBody
(
ConstBuffer
<
void
>
_data
)
:
data
(
ConstBuffer
<
char
>::
FromVoid
(
_data
))
{}
explicit
constexpr
CurlRequestBody
(
StringView
_data
)
:
data
(
_data
)
{}
template
<
typename
T
>
CurlRequestBody
(
CurlRequest
&
request
,
T
_data
)
:
CurlRequestBody
(
_data
)
{
request
.
SetOption
(
CURLOPT_READFUNCTION
,
Callback
);
request
.
SetOption
(
CURLOPT_READDATA
,
this
);
}
private
:
size_t
Read
(
char
*
buffer
,
size_t
size
)
{
size_t
n
=
std
::
min
(
size
,
data
.
size
);
std
::
copy_n
(
data
.
begin
(),
n
,
buffer
);
return
n
;
}
static
size_t
Callback
(
char
*
buffer
,
size_t
size
,
size_t
nitems
,
void
*
instream
)
{
auto
&
rb
=
*
(
CurlRequestBody
*
)
instream
;
return
rb
.
Read
(
buffer
,
size
*
nitems
);
}
};
/**
* The (relevant) contents of a "<D:response>" element.
*/
struct
DavResponse
{
...
...
@@ -253,7 +218,6 @@ ParseU64(const char *s, size_t length)
*/
class
PropfindOperation
:
BlockingHttpRequest
,
CommonExpatParser
{
CurlSlist
request_headers
;
CurlRequestBody
request_body
;
enum
class
State
{
ROOT
,
...
...
@@ -270,13 +234,7 @@ class PropfindOperation : BlockingHttpRequest, CommonExpatParser {
public
:
PropfindOperation
(
CurlGlobal
&
_curl
,
const
char
*
_uri
,
unsigned
depth
)
:
BlockingHttpRequest
(
_curl
,
_uri
),
CommonExpatParser
(
ExpatNamespaceSeparator
{
'|'
}),
request_body
(
request
,
"<?xml version=
\"
1.0
\"
?>
\n
"
"<a:propfind xmlns:a=
\"
DAV:
\"
>"
"<a:prop><a:getcontenttype/></a:prop>"
"<a:prop><a:getcontentlength/></a:prop>"
"</a:propfind>"
)
CommonExpatParser
(
ExpatNamespaceSeparator
{
'|'
})
{
request
.
SetOption
(
CURLOPT_CUSTOMREQUEST
,
"PROPFIND"
);
...
...
@@ -286,6 +244,13 @@ public:
request
.
SetOption
(
CURLOPT_HTTPHEADER
,
request_headers
.
Get
());
request
.
SetOption
(
CURLOPT_POSTFIELDS
,
"<?xml version=
\"
1.0
\"
?>
\n
"
"<a:propfind xmlns:a=
\"
DAV:
\"
>"
"<a:prop><a:getcontenttype/></a:prop>"
"<a:prop><a:getcontentlength/></a:prop>"
"</a:propfind>"
);
// TODO: send request body
}
...
...
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