Skip to content

Refactor/code quality improvements#67

Merged
santoru merged 2 commits into
masterfrom
refactor/code-quality-improvements
Mar 7, 2026
Merged

Refactor/code quality improvements#67
santoru merged 2 commits into
masterfrom
refactor/code-quality-improvements

Conversation

@santoru

@santoru santoru commented Mar 7, 2026

Copy link
Copy Markdown
Owner

No description provided.

santoru and others added 2 commits March 7, 2026 12:15
…_port slash, stdout redirect

#4 Remove no-op 'global json_headers' declaration from main(); json_headers
   is a loop-local variable and the global declaration had no effect.

#5 Remove misleading 'if' in normalize(): socket.inet_aton() always returns
   truthy bytes when it doesn't raise, so the condition was never False.

#6 Replace runtime .lower() calls on string literals with their lowercase
   equivalents ('Content-Security-Policy'.lower() -> 'content-security-policy'
   etc.) in the header-checking loop and frame-ancestors pop.

#7 append_port no longer adds a trailing slash when the input URL didn't have
   one (http://example.com:8080 instead of http://example.com:8080/).

#8 Remove the sys.stdout -> devnull redirect under -j: log() already
   suppresses output when json_output=True, making the redirect redundant.
   Removing it also eliminates the file handle leak and lets test helpers
   use a simple patch('sys.stdout') instead of the __stdout__/finally dance.
   Drop now-unused 'import os'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix #1: -g now normalises to usemethod='GET' in parse_options so it
  no longer silently overrides -m; check_target accepts usemethod param
- Fix #2: client_headers mutation in main() replaced with a local copy
- Fix #3: parse_headers() returns dict instead of writing to global;
  module-level headers variable removed
- Fix #4: darkcolours/lightcolours merged into a single _make_colours()
  factory (only WARNING differed between the two classes)
- Fix #5: parse_options() moved before main()
- Fix #6: NoRedirectHandler moved to module level instead of being
  redefined inside build_opener() on every call
- Fix #7: bare try/except Exception: pass around resp.status removed
- Fix #8: SSL error message indentation artifact from line continuation fixed
- Fix #9: build_opener() called once in main() before the target loop
  instead of once per target inside check_target()
- Fix #10: check_target() no longer reads from global options; options=None
  added at module level to make the dependency explicit
- Fix #11: is_https() inlined at its single call site and removed
- Fix #12: trailing whitespace removed
- Fix #13: replace optparse with argparse
- Fix #14: NoRedirectHandler._handle_redirect docstring updated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@santoru santoru merged commit bb45434 into master Mar 7, 2026
5 checks passed
@santoru santoru deleted the refactor/code-quality-improvements branch March 7, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant