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
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 2, 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
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 4, 2023
CURL: Contrastive Unsupervised Representations for Reinforcement Learning

CURL Rainbow Status: Archive (code is provided as-is, no updates expected) This is an implementation of CURL: Contrastive Unsupervised Representations

Aravind Srinivas 46 Dec 12, 2022
A low-code tool that generates python crawler code based on curl or url

KKBA Intruoduction A low-code tool that generates python crawler code based on curl or url Requirement Python >= 3.6 Install pip install kkba Usage Co

null 8 Sep 20, 2021
Osu statistics right on your desktop, made with pyqt

Osu!Stat Osu statistics right on your desktop, made with Qt5 Credits Would like to thank these creators for their projects and contributions. ppy, osu

Aditya Gupta 21 Jul 13, 2022
A simple, transparent, open-source key logger, written in Python, for tracking your own key-usage statistics.

A simple, transparent, open-source key logger, written in Python, for tracking your own key-usage statistics, originally intended for keyboard layout optimization.

Ga68 56 Jan 3, 2023
pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

pypinfo: View PyPI download statistics with ease. pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery. Installation pypin

Ofek Lev 351 Dec 26, 2022
Tarstats - A simple Python commandline application that collects statistics about tarfiles

A simple Python commandline application that collects statistics about tarfiles.

Kristian Koehntopp 13 Feb 20, 2022
Pihole-eink-display - A simple Python script to display PiHole statistics on an eInk Display

Pihole-eink-display - A simple Python script to display PiHole statistics on an eInk Display

Mark McIntyre 64 Oct 11, 2022
Discord Auto bumper made in python, just a simple auto bumper that I made.

Discord Auto bumper made in python, just a simple auto bumper that I made.

XPTGR 0 Dec 4, 2021
Supply a wrapper ``StockDataFrame`` based on the ``pandas.DataFrame`` with inline stock statistics/indicators support.

Stock Statistics/Indicators Calculation Helper VERSION: 0.3.2 Introduction Supply a wrapper StockDataFrame based on the pandas.DataFrame with inline s

Cedric Zhuang 1.1k Dec 28, 2022
Supply a wrapper ``StockDataFrame`` based on the ``pandas.DataFrame`` with inline stock statistics/indicators support.

Stock Statistics/Indicators Calculation Helper VERSION: 0.3.2 Introduction Supply a wrapper StockDataFrame based on the pandas.DataFrame with inline s

Cedric Zhuang 1.1k Dec 28, 2022
Summary statistics of geospatial raster datasets based on vector geometries.

rasterstats rasterstats is a Python module for summarizing geospatial raster datasets based on vector geometries. It includes functions for zonal stat

Matthew Perry 437 Dec 23, 2022
One Stop Anomaly Shop: Anomaly detection using two-phase approach: (a) pre-labeling using statistics, Natural Language Processing and static rules; (b) anomaly scoring using supervised and unsupervised machine learning.

One Stop Anomaly Shop (OSAS) Quick start guide Step 1: Get/build the docker image Option 1: Use precompiled image (might not reflect latest changes):

Adobe, Inc. 148 Dec 26, 2022
Prometheus exporter for several chia node statistics

prometheus-chia-exporter Prometheus exporter for several chia node statistics It's assumed that the full node, the harvester and the wallet run on the

null 30 Sep 19, 2022
Statistics and Visualization of acceptance rate, main keyword of CVPR 2021 accepted papers for the main Computer Vision conference (CVPR)

Statistics and Visualization of acceptance rate, main keyword of CVPR 2021 accepted papers for the main Computer Vision conference (CVPR)

Hoseong Lee 78 Aug 23, 2022
COVID-19 deaths statistics around the world

COVID-19-Deaths-Dataset COVID-19 deaths statistics around the world This is a daily updated dataset of COVID-19 deaths around the world. The dataset c

Nisa Efendioğlu 4 Jul 10, 2022
A corona statistics and information telegram bot.

A corona statistics and information telegram bot.

Fayas Noushad 15 Oct 21, 2022
Pytorch implementation of CVPR2021 paper "MUST-GAN: Multi-level Statistics Transfer for Self-driven Person Image Generation"

MUST-GAN Code | paper The Pytorch implementation of our CVPR2021 paper "MUST-GAN: Multi-level Statistics Transfer for Self-driven Person Image Generat

TianxiangMa 46 Dec 26, 2022