https_server.py
def extract_ua_str(request):
    """Attempts to extract a User-Agent string from an HTTP GET request.

    If the GET request contains a User-Agent string, it will extract just the
    UA string.

    Args:
        request (:obj: `str`) full HTTP GET Request

    Returns:
        (:obj: `bytes`) the UA string, or 'Unknown' if it is not found
    """

    _LOGGER.debug("Attempting to Extract User-Agent String")

    ua_idx = request.lower().find(b"user-agent")
    if ua_idx >= 0:
        new_substr = request[ua_idx + len("User-Agent: "):]
        end_ua_idx = new_substr.find(b"\r\n")
        # returns the UA string if found
        return new_substr[:end_ua_idx]

    # returns unknown if no UA string
    return b"Unknown"
Attempts to extract a User-Agent string from an HTTP GET request.

    If the GET request contains a User-Agent string, it will extract just the
    UA string.

    Args:
        request (:obj: `str`) full HTTP GET Request

    Returns:
        (:obj: `bytes`) the UA string, or 'Unknown' if it is not found
    
Attempts to extract a User-Agent string from an HTTP GET request.
If the GET request contains a User-Agent string, it will extract just the
UA string.
Attempts to extract a User - Agent string from an HTTP GET request . If the GET request contains a User - Agent string it will extract just the UA string .
def extract_ua_str(request):
    _LOGGER.debug("Attempting to Extract User-Agent String")
    ua_idx = request.lower().find(b"user-agent")
    if ua_idx >= 0:
        new_substr = request[ua_idx + len("User-Agent: "):]
        end_ua_idx = new_substr.find(b"\r\n")
        return new_substr[:end_ua_idx]
    return b"Unknown"
def extract_ua_str ( request ) : _LOGGER . debug ( "Attempting to Extract User-Agent String" ) ua_idx = request . lower ( ) . find ( b"user-agent" ) if ua_idx >= 0 : new_substr = request [ ua_idx + len ( "User-Agent: " ) : ] end_ua_idx = new_substr . find ( b"\r\n" ) return new_substr [ : end_ua_idx ] return b"Unknown"
Attempts to extract a User-Agent string from an HTTP GET request.
Attempts to extract a User - Agent string from an HTTP GET request .
"""Attempts to extract a User-Agent string from an HTTP GET request.

    If the GET request contains a User-Agent string, it will extract just the
    UA string.

    Args:
        request (:obj: `str`) full HTTP GET Request

    Returns:
        (:obj: `bytes`) the UA string, or 'Unknown' if it is not found
    """ # returns the UA string if found # returns unknown if no UA string
`bytes`) the UA string, or 'Unknown' if it is not found
` bytes ` ) the UA string or ' Unknown ' if it is not found
(
request
request (
`str`) full HTTP GET Request
` str ` ) full HTTP GET Request