09-basic-logic.py 894 B

123456789101112131415161718192021222324252627
  1. from pathlib import Path
  2. from httphound.main import BaseProxyTest, BackendConfig, ProxyConfig
  3. class ExampleLogicTest(BaseProxyTest):
  4. """Test to demonstrate how to use internal variable to perform some
  5. actions.
  6. """
  7. def __init__(self):
  8. super().__init__()
  9. self.description = "Example logic test"
  10. self.proxy_config = ProxyConfig(
  11. binary_path=Path.home() / "bin/haproxy"
  12. )
  13. def run_test(self):
  14. # Perform 2 requests with different headers
  15. self.headers = {"X-Test": "1234"}
  16. res1 = self.make_request()
  17. print(f"Response 1 {res1}")
  18. # Check headers received by the backend
  19. print(self.backend.received_headers)
  20. self.headers = {"X-Another": "abcd"}
  21. res2 = self.make_request()
  22. print(f"Response 2 {res2}")
  23. print(self.backend.received_headers)
  24. return True