HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/http.cpython-310.pyc
o

�N�g��@sVdZddlZddlZddlZddlZdgZe�e�Z					d	dd�Z	d
dd�Z
dS)zl
HTTP monitoring states

Perform an HTTP query and statefully return the result

.. versionadded:: 2015.5.0
�N�query�stringc
Ks^|ddiid�}|dur|durd|d<|dd7<|Sd|vr&d|d<d	|d
<d	|d<tdr6d	|d<|rEtd
|fd|i|��}n
td|fi|��}|dur�|dkr�t|�|�d
d�vrrd	|d<|dd|�d�7<nDd|d<|dd|�d�7<n3|dkr�t�t|�t|�d
d���r�d	|d<|dd|�d�7<nd|d<|dd|�d�7<|du�rt|dkr�|D]$}	t|�dd��t|	�kr�|dd|	�d�7<|ddur�d	|d<q�|dd	ur�|dd|�d�7<d|d<nw|dk�r:t�t|�t|�dd����r)|dd|�d�7<|ddu�r(d	|d<nK|dd|�d�7<d|d<n:|dk�rtt|�dd��t|�k�rd|dd|�d�7<|ddu�rcd	|d<n|dd|�d�7<d|d<|d��|d<tdd	u�r�d|d<|dd7<d|v�r�|dd�|d�7<|dd 7<||d!<|S)"a�	
    Perform an HTTP query and statefully return the result

    Passes through all the parameters described in the
    :py:func:`utils.http.query function <salt.utils.http.query>`:

    name
        The name of the query.

    match
        Specifies a pattern to look for in the return text. By default, this will
        perform a string comparison of looking for the value of match in the return
        text.

    match_type
        Specifies the type of pattern matching to use on match. Default is ``string``, but
        can also be set to ``pcre`` to use regular expression matching if a more
        complex pattern matching is required.

        .. note::

            Despite the name of ``match_type`` for this argument, this setting
            actually uses Python's ``re.search()`` function rather than Python's
            ``re.match()`` function.

    status
        The status code for a URL for which to be checked. Can be used instead of
        or in addition to the ``match`` setting. This can be passed as an individual status code
        or a list of status codes.

    status_type
        Specifies the type of pattern matching to use for status. Default is ``string``, but
        can also be set to ``pcre`` to use regular expression matching if a more
        complex pattern matching is required. Additionally, if a list of strings representing
        statuses is given, the type ``list`` can be used.

        .. versionadded:: 3000

        .. note::

            Despite the name of ``match_type`` for this argument, this setting
            actually uses Python's ``re.search()`` function rather than Python's
            ``re.match()`` function.

    If both ``match`` and ``status`` options are set, both settings will be checked.
    However, note that if only one option is ``True`` and the other is ``False``,
    then ``False`` will be returned. If this case is reached, the comments in the
    return data will contain troubleshooting information.

    For more information about the ``http.query`` state, refer to the
    :ref:`HTTP Tutorial <tutorial-http>`.

    .. code-block:: yaml

        query_example:
          http.query:
            - name: 'http://example.com/'
            - status: 200

        query_example2:
          http.query:
            - name: 'http://example.com/'
            - status:
                - 200
                - 201
            - status_type: list

    N�)�name�result�commentZchanges�dataFrrzA Either match text (match) or a status code (status) is required.�decodeT�text�status�testzhttp.wait_for_successful_query�wait_forz
http.queryrz
 Match text "z" was found.z" was not found.Zpcrez Match pattern "�listz Status z was found.z
 Statuses z were not found.z Status pattern "z was not found.z (TEST MODEZtest_urlz, TEST URL WAS: {}�)r)Z__opts__Z__salt__�str�get�re�search�strip�format)
r�matchZ
match_typerZstatus_typer
�kwargs�retr�stat�r�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/http.pyrs�O������
��
�

�
�,c	
Ks�t��}	d}d}d}d}zt|fi|��}|dr|WSWnty7}z
t��\}}}WYd}~nd}~wwt��||krK|sI|rI|�|��|Sd|vr^t�d|d�t�|d�q)a	
    Like query but, repeat and wait until match/match_type or status is fulfilled. State returns result from last
    query state in case of success or if no successful query was made within wait_for timeout.

    name
        The name of the query.

    wait_for
        Total time to wait for requests that succeed.

    request_interval
        Optional interval to delay requests by N seconds to reduce the number of requests sent.

    .. note::

        All other arguments are passed to the http.query state.
    TNrZrequest_intervalzdelaying query for %s seconds.)	�timer�	Exception�sys�exc_info�with_traceback�log�debug�sleep)	rr
rZ	starttimeZcaught_exceptionZexception_typeZ
stacktracer�excrrr�wait_for_successful_query�s.���
�r&)NrNrN)r)�__doc__�loggingrrrZ__monitor__�	getLogger�__name__r"rr&rrrr�<module>s �

�*