Beispiel #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.format_header(self.key.get_generator(settings), value)
Beispiel #2
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
        )
Beispiel #3
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()
             ]
         )
Beispiel #4
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()
             ]
         )
 def test_user_agent(self):
     r = parse_request('GET:/:r:ua')
     assert len(r.headers) == 1
     assert r.headers[0].values(default_settings()) == (b"user-agent", user_agents.get_by_shortcut('a')[2].encode())
Beispiel #6
0
def test_get_shortcut():
    assert user_agents.get_by_shortcut("c")[0] == "chrome"
    assert not user_agents.get_by_shortcut("_")
 def test_user_agent(self):
     r = parse_request('GET:/:r:ua')
     assert len(r.headers) == 1
     assert r.headers[0].values(default_settings()) == (b"user-agent", user_agents.get_by_shortcut('a')[2].encode())