Skip to content

Commit

Permalink
Merge pull request #31622 from jfindlay/query_doc
Browse files Browse the repository at this point in the history
doc/topics/tutorials/http: update query decoding docs
  • Loading branch information
Nicole Thomas committed Mar 2, 2016
2 parents dbf6e07 + 4e48fec commit 6d31b89
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions doc/topics/tutorials/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d31b89

Please sign in to comment.