Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 2.2 KB

File metadata and controls

60 lines (43 loc) · 2.2 KB

HTTP Status Checker: Implementation plan

This tool will leverage the requests and click libraries to build a simple CLI program that can be used to check the health of multiple URLs.

Core Functionality Requirements

  1. URL Status Checking

    • Check the HTTP status of one or more URLs
    • Return appropriate status codes (200 OK, 404, 500, etc.) with reason phrases
    • Handle successful responses (2xx status codes) as "OK"
    • Handle error responses with actual status code and reason
  2. Exception Handling

    • Handle timeout errors and return "TIMEOUT" status
    • Handle connection errors and return "CONNECTION_ERROR" status
    • Handle general request exceptions and return "REQUEST_ERROR: {ExceptionType}" status
    • Gracefully handle any unexpected request-related errors
  3. Configurable Timeout

    • Support configurable timeout for HTTP requests (default: 5 seconds)
    • Apply timeout consistently across all URL checks
  4. Batch Processing

    • Process multiple URLs in a single operation
    • Return results as a dictionary mapping URLs to their status
    • Handle empty URL lists gracefully

CLI Interface Requirements

  1. Command Line Interface

    • Accept multiple URLs as command line arguments
    • Provide --timeout option to configure request timeout
    • Provide --verbose/-v flag for debug logging
    • Display usage information when no URLs provided
  2. Output Formatting

    • Display results in a formatted table-like structure
    • Use color coding (green for success, red for errors)
    • Show URL and corresponding status for each check

Logging Requirements

  1. Comprehensive Logging
    • Log start and completion of URL checking operations
    • Log individual URL check attempts at debug level
    • Log warnings for timeouts and connection errors
    • Log errors for unexpected exceptions with full stack traces
    • Support configurable log levels (INFO by default, DEBUG with verbose flag)

Installation & Distribution Requirements

  1. Package Distribution
    • Installable as a Python package
    • Provide console script entry point (check-urls command)
    • Include proper dependency management (requests, click)
    • Support Python 3.9+ compatibility