示例#1
0
    def values(self, settings):
        value = self.value.val
        if self.option_used:
            value = user_agents.get_by_shortcut(
                value.lower().decode())[2].encode()

        return (self.key.get_generator(settings), value)
示例#2
0
 def set_user_agent(self, k):
     ua = user_agents.get_by_shortcut(k)
     if ua:
         self.walker.add_value(
             [
                 b"User-Agent",
                 ua[2].encode()
             ]
         )
示例#3
0
    def values(self, settings):
        value = self.value.val
        if self.option_used:
            value = user_agents.get_by_shortcut(value.lower().decode())[2].encode()

        return self.format_header(
            self.key.get_generator(settings),
            value
        )
示例#4
0
    def values(self, settings):
        value = self.value.val
        if self.option_used:
            value = user_agents.get_by_shortcut(value.lower())[2]

        return (
            self.key.get_generator(settings),
            value
        )
示例#5
0
 def set_user_agent(self, k):
     ua = user_agents.get_by_shortcut(k)
     if ua:
         self.walker.add_value(
             [
                 b"User-Agent",
                 ua[2].encode()
             ]
         )
示例#6
0
 def set_user_agent(self, k):
     ua = user_agents.get_by_shortcut(k)
     if ua:
         self.walker.add_value(
             [
                 ".*",
                 "User-Agent",
                 ua[2]
             ]
         )
示例#7
0
def test_get_shortcut():
    assert user_agents.get_by_shortcut("c")[0] == "chrome"
    assert not user_agents.get_by_shortcut("_")
示例#8
0
 def set_user_agent(self, k):
     ua = user_agents.get_by_shortcut(k)
     if ua:
         self.walker.add_value([".*", "User-Agent", ua[2]])
示例#9
0
 def test_user_agent(self):
     r = parse_request('GET:/:r:ua')
     assert len(r.headers) == 1
     assert r.headers[0].values(default_settings()) == ("user-agent", user_agents.get_by_shortcut('a')[2])
 def test_user_agent(self):
     r = parse_request('GET:/:r:ua')
     assert len(r.headers) == 1
     assert r.headers[0].values(
         default_settings()) == ("user-agent",
                                 user_agents.get_by_shortcut('a')[2])
示例#11
0
    def values(self, settings):
        value = self.value.val
        if self.option_used:
            value = user_agents.get_by_shortcut(value.lower())[2]

        return self.format_header(self.key.get_generator(settings), value)