from gi.repository import Soup

soup_uri = Soup.URI.new('http://localhost:8000')
message = Soup.Message(method='GET', uri=soup_uri)
session = Soup.SessionAsync()

# didn't find a better way to get the corresponding enum from the
# code, which is of type 'long'
def lookup_code(status_code):
    status_code_enums = []
    for enum in (getattr(Soup.KnownStatusCode, e) for e in dir(Soup.KnownStatusCode)):
        if enum.__class__ == Soup.KnownStatusCode:
            status_code_enums.append(enum)

    for enum in status_code_enums:
        if enum == message.props.status_code:
            return enum

    return None

session.send_message(message)
print lookup_code(message.props.status_code)
print message.props.reason_phrase
