All Projects → httpie → Httpcat

httpie / Httpcat

Licence: other
httpcat is a simple utility for constructing raw HTTP requests on the command line.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Httpcat

Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+48571.56%)
Mutual labels:  api, api-testing, cli, terminal, debugging
Lucid
A simple mock-application for programs that work with child processes
Stars: ✭ 45 (-58.72%)
Mutual labels:  cli, terminal, command-line, debugging
Http Prompt
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
Stars: ✭ 8,329 (+7541.28%)
Mutual labels:  api, api-testing, cli, terminal
Run
⚡The resource runtime
Stars: ✭ 90 (-17.43%)
Mutual labels:  api, cli, terminal, command-line
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+2488.07%)
Mutual labels:  utility, cli, terminal, command-line
Ed
A modern UNIX ed (line editor) clone written in Go
Stars: ✭ 44 (-59.63%)
Mutual labels:  cli, terminal, command-line
Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-51.38%)
Mutual labels:  cli, terminal, command-line
Rang
A Minimal, Header only Modern c++ library for terminal goodies 💄✨
Stars: ✭ 1,080 (+890.83%)
Mutual labels:  cli, terminal, command-line
Navi
An interactive cheatsheet tool for the command-line
Stars: ✭ 10,055 (+9124.77%)
Mutual labels:  cli, terminal, command-line
Clifx
Declarative framework for building command line interfaces
Stars: ✭ 900 (+725.69%)
Mutual labels:  cli, terminal, command-line
Fsq
A tool for querying the file system with a SQL-like language.
Stars: ✭ 60 (-44.95%)
Mutual labels:  cli, terminal, command-line
Window Size
Reliable way to to get the height and width of the terminal/console in a node.js environment.
Stars: ✭ 79 (-27.52%)
Mutual labels:  cli, terminal, command-line
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-68.81%)
Mutual labels:  cli, terminal, command-line
Executor
Watch for file changes and then execute command. Very nice for test driven development.
Stars: ✭ 14 (-87.16%)
Mutual labels:  utility, cli, command-line
Pypistats
Command-line interface to PyPI Stats API to get download stats for Python packages
Stars: ✭ 86 (-21.1%)
Mutual labels:  api, cli, command-line
Word Wrap
Wrap words to a specified length.
Stars: ✭ 107 (-1.83%)
Mutual labels:  cli, terminal, command-line
Cross Platform Node Guide
📗 How to write cross-platform Node.js code
Stars: ✭ 1,161 (+965.14%)
Mutual labels:  api, cli, terminal
Rundeck Cli
CLI tool for Rundeck
Stars: ✭ 98 (-10.09%)
Mutual labels:  api, cli, command-line
Cheat.sh
the only cheat sheet you need
Stars: ✭ 27,798 (+25402.75%)
Mutual labels:  cli, terminal, command-line
Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+28187.16%)
Mutual labels:  cli, terminal, command-line

httpcat

Build Status

httpcat is a simple utility for constructing raw HTTP requests on the command line.

Why?

Sometimes it is useful to be able to create an actual raw HTTP request on the command line:

  • To debug a server issue
  • To test the handling of invalid HTTP requests
  • To learn how HTTP works under the hood

In such cases, existing CLI HTTP clients—such as httpie, curl, or wget —are too high-level as they provide an abstraction layer and one doesn't have a complete control over the exact raw data that gets written to the HTTP socket connection.

Lower-level tools, such as the popular netcat, are better suited for this job.

However, the syntax of HTTP requires headers to be separated with \r\n which makes it difficult to produce them on the command line. A typical solution involves the use of echo:

$ echo -ne 'POST /post HTTP/1.1\r\nHost: httpbin.org\r\nContent-Length: 5\r\n\r\nHello' | \
    nc localhost 8000

httpcat makes this easier:

How it works

  1. Reads command arguments as lines and then lines from stdin
  2. Auto-completes them, if necessary
  3. Writes them to stdout

Features

  • Automatic \r\n completion
  • Automatic Method completion in Request-Line
  • Automatic HTTP-Version completion in Request-Line

Usage

Interactively create a request and send it with nc:

$ httpcat -v | nc httpbin.org 80
POST /post HTTP/1.1
> POST /post HTTP/1.1\r\n
Host: httpbin.org
> Host: httpbin.org\r\n
Content-Length: 6
> Content-Length: 6\r\n

> \r\n
Hello
> Hello

Specify the whole request in the arguments. Here '' represents an empty line which will be converted to \r\n\ separating the headers and the body. Note also that the omitted HTTP-Version is auto-completed:

$ httpcat -v 'POST /post' 'Host: httpbin.org' 'Content-Length: 5' '' 'Hello'  | nc httpbin.org 80
> POST /post HTTP/1.1\r\n
> Host: httpbin.org\r\n
> Content-Length: 5\r\n
> \r\n
> Hello

Omitted Method is set to GET and HTTP-Version is auto-completed:

$ httpcat -v / 'Host: example.org' '' | nc example.org 80
> GET / HTTP/1.1\r\n
> Host: example.org\r\n
> \r\n

You can, for example, use stdin for data and arguments for headers:

$ cat file.txt | httpcat -v 'POST /post' 'Host: httpbin.org' 'Content-Length: 16' '' | nc httpbin.org 80
> POST /post HTTP/1.1\r\n
> Host: httpbin.org\r\n
> Content-Length: 16\r\n
> \r\n
> Hello from file

See also httpcat --help:

usage: httpcat [-h] [-V, --version] [-v] [-n] [line [line ...]]

Create raw HTTP requests on the command line.

positional arguments:
  line            input lines read before lines from stdin

optional arguments:
  -h, --help      show this help message and exit
  -V, --version   show program's version number and exit
  -v, --verbose   print info about output lines to stderr
  -n, --no-stdin  disable reading of lines from stdin

Dependencies

  • Python 3

Installation

pip3 install httpcat

Alternatively, you can just download httpcat.py manually and invoke it as ./httpcat.py instead of httpcat.

Tests

python3 setup.py test

HTTPie offline mode

HTTPie starting with version 2.0.0 also provides an --offline mode. This makes it a good alternative to httpcat because it provides a convenient mechanism for crafting arbitrary HTTP requests without sending them using the user-friendly HTTPie syntax, for example:

echo -n 'Hello' | http --offline POST httpbin.org/post

The above command generates the following output:

POST /post HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 5
Content-Type: application/json
Host: httpbin.org
User-Agent: HTTPie/2.2.0

Hello

The output is valid HTTP, so it can simply be sent using nc:

$ echo -n 'Hello' | http --offline POST httpbin.org/post | nc httpbin.org 80

Changelog

  • 0.0.2 (2016-12-13)

    • Added -v, --verbose and the command is more quiet by default.
    • Added -n, --no-stdin
    • Added -h, --help
    • Added -V, --version
  • 0.0.1 (2016-12-12)

    • Initial release.

Contact

Jakub Roztocil

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].