mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #31622 from jfindlay/query_doc
doc/topics/tutorials/http: update query decoding docs
This commit is contained in:
commit
6d31b8918f
@ -224,12 +224,18 @@ of Salt's internal structure. Historically, the extension for this file is
|
||||
Return Data
|
||||
~~~~~~~~~~~
|
||||
|
||||
By default, ``query()`` will attempt to decode the return data. Because it was
|
||||
designed to be used with REST interfaces, it will attempt to decode the data
|
||||
received from the remote server. First it will check the ``Content-type`` header
|
||||
to try and find references to XML. If it does not find any, it will look for
|
||||
references to JSON. If it does not find any, it will fall back to plain text,
|
||||
which will not be decoded.
|
||||
.. note:: Return data encoding
|
||||
|
||||
If ``decode`` is set to ``True``, ``query()`` will attempt to decode the
|
||||
return data. ``decode_type`` defaults to ``auto``. Set it to a specific
|
||||
encoding, ``xml``, for example, to override autodetection.
|
||||
|
||||
Because Salt's http library was designed to be used with REST interfaces,
|
||||
``query()`` will attempt to decode the data received from the remote server
|
||||
when ``decode`` is set to ``True``. First it will check the ``Content-type``
|
||||
header to try and find references to XML. If it does not find any, it will look
|
||||
for references to JSON. If it does not find any, it will fall back to plain
|
||||
text, which will not be decoded.
|
||||
|
||||
JSON data is translated into a dict using Python's built-in ``json`` library.
|
||||
XML is translated using ``salt.utils.xml_util``, which will use Python's
|
||||
|
Loading…
Reference in New Issue
Block a user