carbon

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2022 License: MIT Imports: 11 Imported by: 0

README

Carbon

Carbon is a tool that issues HTTP requests, then parses, sorts and displays relevant HTTP response headers.

NOTE: The name 'carbon' comes from carbon filtering: method of filtering impurities.

By default it will display all response headers with coloured keys, but headers can also be filtered, as well as parsed into JSON for easier piping/analysis...

Example output of running the carbon executable

Install

go install github.com/integralist/carbon@latest

Build

To build and install the carbon executable locally, then run:

make install

Usage

carbon -help

Usage of carbon:
  -filter string
        comma-separated list of headers to be displayed
        e.g. cache,vary
  -help
        show available flags
  -json
        output is formatted into JSON for easy parsing
  -plain
    	  output is formatted without any extraneous spacing or ANSI colour codes

No filter...

carbon https://www.fastly.com/

Accept-Ranges:
  [bytes]

Cache-Control:
  [max-age=0, private, must-revalidate]

Content-Type:
  [text/html]

Date:
  [Tue, 27 Oct 2020 09:55:39 GMT]

Etag:
  ["c248491ee6293167e071523b47b4625e"]

Server:
  [Artisanal bits]

Strict-Transport-Security:
  [max-age=31536000]

Vary:
  [Accept-Encoding]

X-Cache:
  [HIT]

X-Content-Type-Options:
  [nosniff]

X-Frame-Options:
  [DENY]

X-Xss-Protection:
  [1; mode=block]

Status Code: 200 OK

With filter...

carbon -filter cache,vary https://www.fastly.com

Cache-Control:
  [max-age=0, private, must-revalidate]

Vary:
  [Accept-Encoding]

X-Cache:
  [HIT]

Status Code: 200 OK

With filter AND json...

carbon -filter cache,vary --json https://www.fastly.com

[{"Key":"Cache-Control","Val":["max-age=0, private, must-revalidate"]},{"Key":"Vary","Val":["Accept-Encoding"]},{"Key":"X-Cache","Val":["HIT"]},{"Key":"X-Cache-Hits","Val":["2"]}]

Plain...

carbon -filter cache,vary -plain https://www.fastly.com

Cache-Control: max-age=0, private, must-revalidate
Vary: Accept-Encoding
X-Cache: HIT
Status Code: 200 OK

Tests?

Nope. This was just a quick hack

Bash Alternative?

Here's an official repo for the Bash version](https://github.com/Integralist/Bash-Headers) (if you're interested).

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL