curl statistics made simple

Overview

httpstat

screenshot

httpstat visualizes curl(1) statistics in a way of beauty and clarity.

It is a single file 🌟 Python script that has no dependency 👏 and is compatible with Python 3 🍻 .

Installation

There are three ways to get httpstat:

  • Download the script directly: wget https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py

  • Through pip: pip install httpstat

  • Through homebrew (macOS only): brew install httpstat

For Windows users, @davecheney's Go version is suggested. → download link

Usage

Simply:

python httpstat.py httpbin.org/get

If installed through pip or brew, you can use httpstat as a command:

httpstat httpbin.org/get

cURL Options

Because httpstat is a wrapper of cURL, you can pass any cURL supported option after the url (except for -w, -D, -o, -s, -S which are already used by httpstat):

httpstat httpbin.org/post -X POST --data-urlencode "a=b" -v

Environment Variables

httpstat has a bunch of environment variables to control its behavior. Here are some usage demos, you can also run httpstat --help to see full explanation.

  • HTTPSTAT_SHOW_BODY

    Set to true to show response body in the output, note that body length is limited to 1023 bytes, will be truncated if exceeds. Default is false.

  • HTTPSTAT_SHOW_IP

    By default httpstat shows remote and local IP/port address. Set to false to disable this feature. Default is true.

  • HTTPSTAT_SHOW_SPEED

    Set to true to show download and upload speed. Default is false.

    HTTPSTAT_SHOW_SPEED=true httpstat http://cachefly.cachefly.net/10mb.test
    
    ...
    speed_download: 3193.3 KiB/s, speed_upload: 0.0 KiB/s
  • HTTPSTAT_SAVE_BODY

    By default httpstat stores body in a tmp file, set to false to disable this feature. Default is true

  • HTTPSTAT_CURL_BIN

    Indicate the cURL bin path to use. Default is curl from current shell $PATH.

    This exampe uses brew installed cURL to make HTTP2 request:

    HTTPSTAT_CURL_BIN=/usr/local/Cellar/curl/7.50.3/bin/curl httpstat https://http2.akamai.com/ --http2
    
    HTTP/2 200
    ...

    cURL must be compiled with nghttp2 to enable http2 feature (#12).

  • HTTPSTAT_METRICS_ONLY

    If set to true, httpstat will only output metrics in json format, this is useful if you want to parse the data instead of reading it.

  • HTTPSTAT_DEBUG

    Set to true to see debugging logs. Default is false

For convenience, you can export these environments in your .zshrc or .bashrc, example:

export HTTPSTAT_SHOW_IP=false
export HTTPSTAT_SHOW_SPEED=true
export HTTPSTAT_SAVE_BODY=false

Related Projects

Here are some implementations in various languages:

  • Go: davecheney/httpstat

    This is the Go alternative of httpstat, it's written in pure Go and relies no external programs. Choose it if you like solid binary executions (actually I do).

  • Go (library): tcnksm/go-httpstat

    Other than being a cli tool, this project is used as library to help debugging latency of HTTP requests in Go code, very thoughtful and useful, see more in this article

  • Bash: b4b4r07/httpstat

    This is what exactly I want to do at the very beginning, but gave up due to not confident in my bash skill, good job!

  • Node: yosuke-furukawa/httpstat

    b4b4r07 mentioned this in his article, could be used as a HTTP client also.

  • PHP: talhasch/php-httpstat

    The PHP implementation by @talhasch

Some code blocks in httpstat are copied from other projects of mine, have a look:

Comments
  • Option to display the IP address used to contact destination

    Option to display the IP address used to contact destination

    It would be nice to find out the exact IP that was used to make the connection. This helps for things like debugging round-robin records etc..

    Maybe something like HTTPSTAT_SHOW_IP

    Great work on this btw, definitely my go to utility now ;)

    enhancement 
    opened by InAnimaTe 6
  • Could not decode json error on OSX

    Could not decode json error on OSX

    Hi! I receive following error on OSX:

    ➜  ~ httpstat https://google.com/
    
    Could not decode json: Expecting property name: line 2 column 22 (char 23)
    curl result: 0 {
    "time_namelookup": 0,068,
    "time_connect": 0,113,
    "time_appconnect": 0,302,
    "time_pretransfer": 0,302,
    "time_redirect": 0,000,
    "time_starttransfer": 0,370,
    "time_total": 0,370,
    "speed_download": 594,000,
    "speed_upload": 0,000
    }
    

    I think, the problem is in number format, it uses a comma instead of dot as a delimiter.

    opened by dizballanze 6
  • server processing time is negative

    server processing time is negative

    Body stored in: /var/folders/fh/5k0fl9xd06xgflnp5d90dz8m0000gn/T/tmpjIYObb
    
      DNS Lookup   TCP Connection   TLS Handshake   Server Processing   Content Transfer
    [     2ms    |      194ms     |     92ms      |      -288ms       |      1255ms      ]
                 |                |               |                   |                  |
        namelookup:2ms            |               |                   |                  |
                            connect:196ms         |                   |                  |
                                        pretransfer:288ms             |                  |
                                                          starttransfer:0ms              |
                                                                                     total:1255ms
    
    opened by lidaobing 5
  • 'failed to create process' after PIP install - Possible Python 3 Compatibility Issue?

    'failed to create process' after PIP install - Possible Python 3 Compatibility Issue?

    Installed via PIP on two separate computers running Windows 10 with Python 3.5.2 and Python 3.5.0 and attempted httpstat google.com in the command line and received 'failed to create process'. Navigated directly in the command line to the default Python scripts folder and ran py httpstat-script.py google.com and received the following on both machines: Traceback (most recent call last): File ".\httpstat-script.py", line 9, in <module> load_entry_point('httpstat==1.2.1', 'console_scripts', 'httpstat')() File "c:\users\%NAME%\appdata\local\programs\python\python35\lib\site-packages\httpstat.py", line 221, in main p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=cmd_env) File "c:\users\%NAME%\appdata\local\programs\python\python35\lib\subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "c:\users\%NAME%\appdata\local\programs\python\python35\lib\subprocess.py", line 1224, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

    Ran repair on my Python installation and retried. Uninstalled and reinstalled Python (using elevated privileges) and retried. No positive effect.

    An attempt on a third Win10 computer with both Python 3.5.1 and Python 2.7 installed worked without issue. Installed via PIP and httpstat google.com ran correctly. Running the script directly on that machine with either version of Python also works without issue.

    needs response 
    opened by SWBennett06 4
  • Screenshots

    Screenshots

    First off Great software ! and the screenshot looks pretty awesome too can you please tell how can I modify my terminal to get that black window bar and that awesome font! I am on macOS.

    Thanks! 😄

    opened by hemangsk 4
  • Installed with pip but not working

    Installed with pip but not working

    Hi there, First thanks for your really awesome tool, my problem with this is that I installed it with pip on ubuntu but my problem is that although I it is installed in the ~/.local/lib/python2.7/site-packages but it isn't available via commandline. I mean when I type httpstat it says command not found.

    opened by Tabrizian 4
  • Detecting connectivity Issues to the destination

    Detecting connectivity Issues to the destination

    I have a networking solution which probes the destination with http, mtr, ping etc and collect metrics. Often I see when MTR, Ping return 100% packet loss, httpstat report a very large value of latency. Is it possible to put a time out in the code (preferably configurable) ?

    opened by atibdialpad 3
  • Valid cURL invocation fails with httpstat because of URL position

    Valid cURL invocation fails with httpstat because of URL position

    An invocation that would be valid with cURL:

    curl -X GET http://www.google.de/

    gives the following error with httpstat:

    $ httpstat -X GET http://www.google.de/
    > curl -w <output-format> -D <tempfile> -o <tempfile> -s -S GET http://www.google.de/ -X
    curl error: curl: option -X: requires parameter
    curl: try 'curl --help' or 'curl --manual' for more information
    
    

    whereas the command

    httpstat http://www.google.de/ -X GET

    is parsed successfully.

    It would be nice if httpstat did not depend on the position of the URL. In my concrete example, the cURL command was generated by Flask-RESTPlus Swagger documentation.

    opened by bbiskup 3
  • 这是抄袭了https://github.com/davecheney/httpstat吗?

    这是抄袭了https://github.com/davecheney/httpstat吗?

    看这个https://github.com/davecheney/httpstat 库的时候,它的readme里有这样一句

    But seriously, https://github.com/reorx/httpstat is the new hotness, and this is a shameless rip off.

    就好奇问问

    opened by hongmaoxiao 2
  • FileNotFoundError on WIN7/Python3.6.0, installed with Pip

    FileNotFoundError on WIN7/Python3.6.0, installed with Pip

    Trying to run httpstat https://google.com on Windows 7 with Python 3.6.0, results a stack trace:

    Traceback (most recent call last):
      File "C:\Users\me\AppData\Local\Programs\Python\Python36\Scripts\httpstat-script.py", line 11, in <module>
        load_entry_point('httpstat==1.2.1', 'console_scripts', 'httpstat')()
      File "c:\users\me\appdata\local\programs\python\python36\lib\site-packages\httpstat.py", line 221, in main
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=cmd_env)
      File "c:\users\me\appdata\local\programs\python\python36\lib\subprocess.py", line 707, in __init__
        restore_signals, start_new_session)
      File "c:\users\me\appdata\local\programs\python\python36\lib\subprocess.py", line 990, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified
    
    opened by janik6n 2
  • Error when running on Linux/Python 2.6

    Error when running on Linux/Python 2.6

    python httpstat.py httpbin.org/get File "httpstat.py", line 110 grayscale = {(i - 232): make_color('38;5;' + str(i)) for i in xrange(232, 256)} ^ SyntaxError: invalid syntax

    Redhat 6.5, Python 2.6

    wontfix 
    opened by GClover1985 2
  • why server processing is 0 with local request

    why server processing is 0 with local request

    curl 7.61.1 (x86_64-redhat-linux-gnu) libcurl/7.61.1 OpenSSL/1.1.1c zlib/1.2.11 brotli/1.0.6 libidn2/2.2.0 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.9.0/openssl/zlib nghttp2/1.33.0

    export  HTTPSTAT_SHOW_IP=true
    export  HTTPSTAT_SHOW_SPEED=true
    export  HTTPSTAT_SAVE_BODY=false
    export  HTTPSTAT_DEBUG=false
    

    Connected to ::1:8094 from ::1:57934

    HTTP/1.1 100 Continue

    HTTP/1.1 200 OK Content-Type: application/json Grpc-Metadata-Content-Type: application/grpc Date: Tue, 31 Aug 2021 12:33:30 GMT Content-Length: 258

      DNS Lookup   TCP Connection   Server Processing   Content Transfer
    [     0ms    |       0ms      |        0ms        |      1405ms      ]
                 |                |                   |                  |
        namelookup:0ms            |                   |                  |
                            connect:0ms               |                  |
                                          starttransfer:0ms              |
                                                                     total:1405ms 
    

    speed_download: 0.2 KiB/s, speed_upload: 36791.2 KiB/s

    opened by zuodd 5
  • Windows color support using colorama

    Windows color support using colorama

    Add:

        extras_require = {
            ':sys_platform=="win32"': ['colorama']
        }
    

    in setup.py; in code, add:

    https://github.com/Qix-/better-exceptions/blob/master/better_exceptions/color.py#L53

    part.

    todo 
    opened by reorx 0
  • Add option for detailing SSL/TLS Certificate

    Add option for detailing SSL/TLS Certificate

    This would be super useful to have for learning more about the certificate a particular site uses. It could be an add-on option (not default) which shows issuer information, if its valid, start/expire, and possibly other details.

    Just an idea!

    opened by InAnimaTe 5
  • Appending the redirect urls stats.

    Appending the redirect urls stats.

    The following changes are done to append the redirect urls stats to the output.

    • [x] Added a new -L option analogous to the curl -L option to follow redirects and print the stats.
    • [x] Changed the code formatting and created new functions run_command, print_stats and run_command_and_print_stats.
    • [x] Appended keys http_code and redirect_curl to the curl format.
    • [x] Added a while loop to print the stats if follow redirects (-L) option is used.

    Sample output:

    HTTP/1.1` 302 Found
    Cache-Control: private
    Content-Type: text/html; charset=UTF-8
    Location: http://www.google.co.in/?gfe_rd=cr&ei=CQPyV8-SBuuK8QeBy7LgCg
    Content-Length: 261
    Date: Mon, 03 Oct 2016 07:04:41 GMT
    
    Body stored in: /tmp/tmpWV9fJm
    
      DNS Lookup   TCP Connection   Server Processing   Content Transfer
    [   0.061ms  |     0.068ms    |      0.076ms      |       0.0ms      ]
                 |                |                   |                  |
        namelookup:0.061ms        |                   |                  |
                            connect:0.129ms           |                  |
                                          starttransfer:0.205ms          |
                                                                     total:0.205ms
    
    HTTP/1.0 200 OK
    Date: Mon, 03 Oct 2016 07:04:41 GMT
    Expires: -1
    Cache-Control: private, max-age=0
    Content-Type: text/html; charset=ISO-8859-1
    P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
    Server: gws
    X-XSS-Protection: 1; mode=block
    X-Frame-Options: SAMEORIGIN
    Set-Cookie: NID=87=KaRf8ZB11GmdE6rn1GjaGNDxO2qL4KPYZfQbNpgHns9wbhBM-Xw3wwioSN14tf3RdRFEcvFFqZdEsn1M9I_qV6Ds8fF40Z6j5w_gm_Ay7yqRlGwVj2ymZPppIGTw16Rx; expires=Tue, 04-Apr-2017 07:04:41 GMT; path=/; domain=.google.co.in; HttpOnly
    Accept-Ranges: none
    Vary: Accept-Encoding
    X-Cache: MISS from localhost
    X-Cache-Lookup: MISS from localhost:8080
    Via: 1.0 localhost (squid/3.1.19)
    Connection: close
    
    Body stored in: /tmp/tmpWV9fJm
    
      DNS Lookup   TCP Connection   Server Processing   Content Transfer
    [   0.253ms  |     0.045ms    |      0.19ms       |      0.045ms     ]
                 |                |                   |                  |
        namelookup:0.253ms        |                   |                  |
                            connect:0.298ms           |                  |
                                          starttransfer:0.488ms          |
                                                                     total:0.533ms
    
    
    
    opened by nishantkshyp2004 0
  • Could not decode json

    Could not decode json

    Windows 7 64-bit, Python 2.7.12 64-bit

    C:\Users\xmr\Desktop>curl --version
    curl 7.50.1 (x86_64-pc-win32) libcurl/7.50.1 OpenSSL/1.0.2h zlib/1.2.8 WinIDN libssh2/1.7.0 nghttp2/1.13.0
    Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
    Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz TLS-SRP HTTP2
    
    C:\Users\xmr\Desktop>httpstat google.com
    ←[38;5;248m←[0m
    ←[33mCould not decode json: Expecting property name: line 2 column 22 (char 24)←
    [0m
    curl result: 0 ←[38;5;248m{
    "time_namelookup": 0,110,
    "time_connect": 0,328,
    "time_appconnect": 0,000,
    "time_pretransfer": 0,328,
    "time_redirect": 0,000,
    "time_starttransfer": 0,391,
    "time_total": 0,391,
    "speed_download": 659,000,
    "speed_upload": 0,000
    }←[0m ←[38;5;248m←[0m
    
    help wanted windows 
    opened by XhmikosR 13
Releases(1.3.0)
Owner
Xiao Meng
Craft and smelt.
Xiao Meng
Asynchronous Python HTTP Requests for Humans using twisted

Asynchronous Python HTTP Requests for Humans Small add-on for the python requests http library. Makes use twisted's ThreadPool, so that the requests'A

Pierre Tardy 32 Oct 27, 2021
Aiosonic - lightweight Python asyncio http client

aiosonic - lightweight Python asyncio http client Very fast, lightweight Python asyncio http client Here is some documentation. There is a performance

Johanderson Mogollon 93 Jan 06, 2023
Detects request smuggling via HTTP/2 downgrades.

h2rs Detects request smuggling via HTTP/2 downgrades. Requirements Python 3.x Python Modules base64 sys socket ssl certifi h2.connection h2.events arg

Ricardo Iramar dos Santos 89 Dec 22, 2022
r - a small subset of Python Requests

r a small subset of Python Requests a few years ago, when I was first learning Python and looking for http functionality, i found the batteries-includ

Gabriel Sroka 4 Dec 15, 2022
A Python obfuscator using HTTP Requests and Hastebin.

🔨 Jawbreaker 🔨 Jawbreaker is a Python obfuscator written in Python3, using double encoding in base16, base32, base64, HTTP requests and a Hastebin-l

Billy 50 Sep 28, 2022
Probe and discover HTTP pathname using brute-force methodology and filtered by specific word or 2 words at once

pathprober Probe and discover HTTP pathname using brute-force methodology and filtered by specific word or 2 words at once. Purpose Brute-forcing webs

NFA 41 Jul 06, 2022
A toolbelt of useful classes and functions to be used with python-requests

The Requests Toolbelt This is just a collection of utilities for python-requests, but don't really belong in requests proper. The minimum tested reque

892 Jan 06, 2023
Aiohttp simple project with Swagger and ccxt integration

crypto_finder What Where Documentation http://localhost:8899/docs Maintainer nordzisko Crypto Finder aiohttp application Application that connects to

Norbert Danisik 5 Feb 27, 2022
Aiohttp-openmetrics - OpenMetrics endpoint provider for aiohttp

aiohttp-openmetrics This project contains a simple middleware and /metrics route

Jelmer Vernooij 1 Dec 15, 2022
Some example code for using a raspberry pi to draw text (including emojis) and twitch emotes to a HUB75 RGB matrix via an HTTP post endpoint.

Some example code for using a raspberry pi to draw text (including emojis) and twitch emotes to a HUB75 RGB matrix via an HTTP post endpoint.

7 Nov 05, 2022
curl statistics made simple

httpstat httpstat visualizes curl(1) statistics in a way of beauty and clarity. It is a single file 🌟 Python script that has no dependency 👏 and is

Xiao Meng 5.3k Jan 04, 2023
Python Simple SOAP Library

PySimpleSOAP / soap2py Python simple and lightweight SOAP library for client and server webservices interfaces, aimed to be as small and easy as possi

PySimpleSOAP 369 Jan 02, 2023
Fast HTTP parser

httptools is a Python binding for the nodejs HTTP parser. The package is available on PyPI: pip install httptools. APIs httptools contains two classes

magicstack 1.1k Jan 07, 2023
A simple, yet elegant HTTP library.

Requests Requests is a simple, yet elegant HTTP library. import requests r = requests.get('https://api.github.com/user', auth=('user', 'pass')

Python Software Foundation 48.8k Jan 05, 2023
Python package for caching HTTP response based on etag

Etag cache implementation for HTTP requests, to save request bandwidth for a non-modified response. Returns high-speed accessed dictionary data as cache.

Rakesh R 2 Apr 27, 2022
🔄 🌐 Handle thousands of HTTP requests, disk writes, and other I/O-bound tasks simultaneously with Python's quintessential async libraries.

🔄 🌐 Handle thousands of HTTP requests, disk writes, and other I/O-bound tasks simultaneously with Python's quintessential async libraries.

Hackers and Slackers 15 Dec 12, 2022
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more.

urllib3 is a powerful, user-friendly HTTP client for Python. Much of the Python ecosystem already uses urllib3 and you should too. urllib3 brings many

urllib3 3.2k Dec 29, 2022
HackerNews digest using GitHub actions

HackerNews Digest This script makes use of GitHub actions to send daily newsletters with the top 10 posts from HackerNews of the previous day. How to

Rajkumar S 3 Jan 19, 2022
Small, fast HTTP client library for Python. Features persistent connections, cache, and Google App Engine support. Originally written by Joe Gregorio, now supported by community.

Introduction httplib2 is a comprehensive HTTP client library, httplib2.py supports many features left out of other HTTP libraries. HTTP and HTTPS HTTP

457 Dec 10, 2022
PycURL - Python interface to libcurl

PycURL -- A Python Interface To The cURL library PycURL is a Python interface to libcurl, the multiprotocol file transfer library. Similarly to the ur

PycURL 933 Jan 09, 2023