aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/proxy/primitives.py
blob: 75ad5482737fb70fc53b923c3469f55ea85d6df1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class ProxyError(Exception):
    def __init__(self, code, msg, headers=None):
        self.code, self.msg, self.headers = code, msg, headers

    def __str__(self):
        return "ProxyError(%s, %s)" % (self.code, self.msg)


class ConnectionTypeChange(Exception):
    """
    Gets raised if the connection type has been changed (e.g. after HTTP/1.1 101 Switching Protocols).
    It's up to the raising ProtocolHandler to specify the new conntype before raising the exception.
    """
    pass


class ProxyServerError(Exception):
    pass


class AddressPriority(object):
    """
    Enum that signifies the priority of the given address when choosing the destination host.
    Higher is better (None < i)
    """
    MANUALLY_CHANGED = 4
    """user changed the target address in the ui"""
    FROM_SETTINGS = 3
    """upstream proxy from arguments (reverse proxy or forward proxy)"""
    FROM_CONNECTION = 2
    """derived from transparent resolver"""
    FROM_PROTOCOL = 1
    """derived from protocol (e.g. absolute-form http requests)"""


class Log:
    def __init__(self, msg):
        self.msg = msg