On Thu, Mar 01, 2018 at 01:58:55PM +0000, Richard W.M. Jones wrote:
> Allow arbitrary HTTP request headers to be set, like this:
>
> qemu-img create -f qcow2 \
> -b 'json:{ "file.driver":"http",
> "file.url":"http://192.168.0.249/scratch/test.img",
> "file.header": ["Authorization: letmein"] }' \
> test.qcow2
>
> which adds the ‘Authorization: letmein’ header to the outgoing request
> for the backing file. Multiple headers can be set, and curl built-in
> headers can be removed (using "Header:").
>
> Note this uses the same format as curl's CURLOPT_HTTPHEADER, thus
> pulling in curl API guarantees into qemu, but curl has had very strong
> API backward compatibility since the start of the project.
It doesn't appear like there's anything really curl specific about
this - isn't 'Key: value' just the standard HTTP format (minus the
\r\n line ending of course. IOW, I don't see any problem with using
this format.
>
> Signed-off-by: Richard W.M. Jones <[email protected]>
> ---
> block/curl.c | 21 ++++++++++++++++++++-
> qapi/block-core.json | 10 ++++++++--
> 2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 5c5921bfb7..ca1ebdbef1 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -3047,12 +3047,15 @@
> # @cookie-secret: ID of a QCryptoSecret object providing the cookie data in a
> # secure way. See @cookie for the format. (since 2.10)
> #
> +# @header: List of HTTP request headers, see CURLOPT_HTTPHEADER(3).
Put a '(since 2.12)' anntation on end of the docs for this new field
> +#
> # Since: 2.9
> ##
> { 'struct': 'BlockdevOptionsCurlHttp',
> 'base': 'BlockdevOptionsCurlBase',
> 'data': { '*cookie': 'str',
> - '*cookie-secret': 'str'} }
> + '*cookie-secret': 'str',
> + '*header': [ 'str' ] } }
>
> ##
> # @BlockdevOptionsCurlHttps:
> @@ -3070,13 +3073,16 @@
> # @cookie-secret: ID of a QCryptoSecret object providing the cookie data in a
> # secure way. See @cookie for the format. (since 2.10)
> #
> +# @header: List of HTTP request headers, see CURLOPT_HTTPHEADER(3).
Same here about version annotation.
> +#
> # Since: 2.9
> ##
> { 'struct': 'BlockdevOptionsCurlHttps',
> 'base': 'BlockdevOptionsCurlBase',
> 'data': { '*cookie': 'str',
> '*sslverify': 'bool',
> - '*cookie-secret': 'str'} }
> + '*cookie-secret': 'str',
> + '*header': [ 'str' ] } }
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|