Skip to content

Port Priority Optimization: Intelligent Protocol Detection Based on Port Numbers #2299

Closed

Description

@coderabbitai

Description

This issue tracks the port priority optimization feature where httpx attempts to intelligently guess the most likely protocol (HTTP or HTTPS) based on port numbers and global service distribution patterns.

Background

When scanning targets with mixed protocols (HTTPorHTTPS or HTTPandHTTPS), httpx needs to determine which protocol to try first. This optimization improves efficiency by making educated guesses based on:

  • Common HTTP ports: Ports like 80, 8080 are more likely to serve HTTP
  • Port ranges: Numeric ports greater than 1024 often serve HTTP
  • Default behavior: When no specific pattern matches, defaults to HTTPS

Implementation

The implementation includes:

  • A determineMostLikelySchemeOrder() function that analyzes the target host:port
  • Logic to prioritize HTTP for common HTTP ports and high-numbered ports
  • Fallback to HTTPS as the default scheme

Related PR

This issue is related to PR #2298 which implements the initial version of this optimization.

PR Link: #2298
Requested by: @Mzack9999

Potential Future Enhancements

  • Expand the list of known service ports
  • Add configuration options for custom port-to-protocol mappings
  • Consider service fingerprinting data from global internet scans
  • Performance metrics to validate the optimization effectiveness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions