aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/data/addonscripts/configure.py
blob: 64abba6e186c320beb0df6d30a501e415293db7a (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
import typing

from mitmproxy import ctx
from mitmproxy import exceptions


class TestHeader:
    def load(self, loader):
        loader.add_option(
            name = "testheader",
            typespec = typing.Optional[int],
            default = None,
            help = "test header",
        )

    def configure(self, updates):
        raise exceptions.OptionsError("Options Error")

    def response(self, flow):
        if ctx.options.testheader is not None:
            flow.response.headers["testheader"] = str(ctx.options.testheader)


addons = [
    TestHeader()
]